6cf6f95f58
CodeQL / Analyze (push) Has been cancelled
Sync to Gitee / Run (push) Has been cancelled
Go / build & test (1.25.x) (push) Has been cancelled
Go / build & test (1.26.x) (push) Has been cancelled
Lint / resolve module (push) Has been cancelled
Lint / lint module (push) Has been cancelled
30 lines
472 B
Go
30 lines
472 B
Go
package xml
|
|
|
|
import (
|
|
"encoding/xml"
|
|
|
|
"github.com/go-kratos/kratos/v3/encoding"
|
|
)
|
|
|
|
// Name is the name registered for the xml codec.
|
|
const Name = "xml"
|
|
|
|
func init() {
|
|
encoding.RegisterCodec(codec{})
|
|
}
|
|
|
|
// codec is a Codec implementation with xml.
|
|
type codec struct{}
|
|
|
|
func (codec) Marshal(v any) ([]byte, error) {
|
|
return xml.Marshal(v)
|
|
}
|
|
|
|
func (codec) Unmarshal(data []byte, v any) error {
|
|
return xml.Unmarshal(data, v)
|
|
}
|
|
|
|
func (codec) Name() string {
|
|
return Name
|
|
}
|