mirror of
https://git.uploadfilter24.eu/lerentis/terraform-provider-gitea.git
synced 2024-11-16 06:58:12 +00:00
.. | ||
codes | ||
.golangci.yml | ||
.travis.yml | ||
appengine.go | ||
CHANGELOG.md | ||
decode.go | ||
decode_map.go | ||
decode_number.go | ||
decode_query.go | ||
decode_slice.go | ||
decode_string.go | ||
decode_value.go | ||
encode.go | ||
encode_map.go | ||
encode_number.go | ||
encode_slice.go | ||
encode_value.go | ||
ext.go | ||
intern.go | ||
LICENSE | ||
Makefile | ||
msgpack.go | ||
README.md | ||
safe.go | ||
time.go | ||
types.go | ||
unsafe.go |
MessagePack encoding for Golang
Supports:
- Primitives, arrays, maps, structs, time.Time and interface{}.
- Appengine *datastore.Key and datastore.Cursor.
- CustomEncoder/CustomDecoder interfaces for custom encoding.
- Extensions to encode type information.
- Renaming fields via
msgpack:"my_field_name"
and alias viamsgpack:"alias:another_name"
. - Omitting individual empty fields via
msgpack:",omitempty"
tag or all empty fields in a struct. - Map keys sorting.
- Encoding/decoding all structs as arrays or individual structs.
- Encoder.UseJSONTag with Decoder.UseJSONTag can turn msgpack into drop-in replacement for JSON.
- Simple but very fast and efficient queries.
API docs: https://godoc.org/github.com/vmihailenco/msgpack. Examples: https://godoc.org/github.com/vmihailenco/msgpack#pkg-examples.
Installation
This project uses Go Modules and semantic import versioning since v4:
go mod init github.com/my/repo
go get github.com/vmihailenco/msgpack/v4
Quickstart
import "github.com/vmihailenco/msgpack/v4"
func ExampleMarshal() {
type Item struct {
Foo string
}
b, err := msgpack.Marshal(&Item{Foo: "bar"})
if err != nil {
panic(err)
}
var item Item
err = msgpack.Unmarshal(b, &item)
if err != nil {
panic(err)
}
fmt.Println(item.Foo)
// Output: bar
}
Benchmark
BenchmarkStructVmihailencoMsgpack-4 200000 12814 ns/op 2128 B/op 26 allocs/op
BenchmarkStructUgorjiGoMsgpack-4 100000 17678 ns/op 3616 B/op 70 allocs/op
BenchmarkStructUgorjiGoCodec-4 100000 19053 ns/op 7346 B/op 23 allocs/op
BenchmarkStructJSON-4 20000 69438 ns/op 7864 B/op 26 allocs/op
BenchmarkStructGOB-4 10000 104331 ns/op 14664 B/op 278 allocs/op
Howto
Please go through examples to get an idea how to use this package.