encoding

package
v0.0.0-...-5870b03 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 10, 2023 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Gob is a Codec that uses the gob package.
	Gob = Codec{gobMarshal, gobUnmarshal}
	// JSON is a Codec that uses the json package.
	// JSON = Codec{json.Marshal, json.Unmarshal}
	JSON = jsoniter.ConfigCompatibleWithStandardLibrary
)
View Source
var (
	GobIO  = CodecIO{gobWriterMarshal, gobReaderUnmarshal}
	JSONIO = CodecIO{jsonWriterMarshal, jsonReaderUnmarshal}
)

Functions

func Base64Decode

func Base64Decode(src string) ([]byte, error)

Base64Decode 解码base64

func Base64Encode

func Base64Encode(src []byte) string

Base64Encode 编码base64

func Snake

func Snake(name string) string

大写转为下划线加小写

Types

type Codec

type Codec struct {
	Marshal   func(interface{}) ([]byte, error)
	Unmarshal func([]byte, interface{}) error
}

Codec 参考https://github.com/golang/appengine/blob/master/memcache/memcache.go

type CodecIO

type CodecIO struct {
	Marshal   func(io.Writer, interface{}) error
	Unmarshal func(io.Reader, interface{}) error
}

type Date

type Date time.Time

func (Date) MarshalJSON

func (t Date) MarshalJSON() ([]byte, error)

func (Date) String

func (t Date) String() string

func (Date) Unix

func (t Date) Unix() int64

func (Date) UnixNano

func (t Date) UnixNano() int64

func (*Date) UnmarshalJSON

func (t *Date) UnmarshalJSON(data []byte) (err error)

type DateTime

type DateTime time.Time

func (DateTime) MarshalJSON

func (t DateTime) MarshalJSON() ([]byte, error)

func (DateTime) String

func (t DateTime) String() string

func (DateTime) Unix

func (t DateTime) Unix() int64

func (DateTime) UnixNano

func (t DateTime) UnixNano() int64

func (*DateTime) UnmarshalJSON

func (t *DateTime) UnmarshalJSON(data []byte) (err error)

type Int

type Int int

把纯数字的字符串也解析成数字

func (*Int) MarshalJSON

func (a *Int) MarshalJSON() (data []byte, err error)

func (*Int) UnmarshalJSON

func (a *Int) UnmarshalJSON(data []byte) (err error)

type Str

type Str string

把数字也解析成字符串

func (*Str) MarshalJSON

func (a *Str) MarshalJSON() (data []byte, err error)

func (*Str) UnmarshalJSON

func (a *Str) UnmarshalJSON(data []byte) (err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL