Add base
This commit is contained in:
20
codec/codec.go
Normal file
20
codec/codec.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package codec
|
||||
|
||||
import "errors"
|
||||
|
||||
var (
|
||||
ErrCodecNotRegistered = errors.New("ceen: codec not registered")
|
||||
|
||||
Default = JSON
|
||||
|
||||
Codecs = map[string]Codec{
|
||||
JSON.Name(): JSON,
|
||||
Binary.Name(): Binary,
|
||||
}
|
||||
)
|
||||
|
||||
type Codec interface {
|
||||
Name() string
|
||||
Marshal(any) ([]byte, error)
|
||||
Unmarshal([]byte, any) error
|
||||
}
|
Reference in New Issue
Block a user