1 Star 0 Fork 0

s-dy / yogurt

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
encoding.go 543 Bytes
一键复制 编辑 原始数据 按行查看 历史
s-dy 提交于 2022-10-22 19:04 . config,encoding, transport
package encoding
import "strings"
type Codec interface {
Marshal(v any) ([]byte, error)
Unmarshal(data []byte, v any) error
Name() string
}
var registeredCodec = make(map[string]Codec)
func RegisterCode(c Codec) {
if c == nil {
panic("cannot register a nil Codec")
}
if c.Name() == "" {
panic("cannot register Codec with empty string result for Name()")
}
contentSubtype := strings.ToLower(c.Name())
registeredCodec[contentSubtype] = c
}
func GetCodec(contentSubtype string) Codec {
return registeredCodec[contentSubtype]
}
1
https://gitee.com/sdynasty/yogurt.git
git@gitee.com:sdynasty/yogurt.git
sdynasty
yogurt
yogurt
01d4da0b550e

搜索帮助

53164aa7 5694891 3bd8fe86 5694891