-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdoc.go
34 lines (34 loc) · 1.49 KB
/
doc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Package plenc provides an efficient serialisation protocol based on protobuf,
// but without requiring .proto files or awkward autogenerated structs. Your
// structs are the basis for the serialisation.
//
// plenc needs you to annotate your structs with a plenc tag on each field. The
// tag either indicates that the field should not be encoded, or provides a
// persistent index number that's used for that field in the encoding. The
// indexes within a struct must all be unique and should not be changed. You may
// remove fields, but you should not re-use the index number of a removed field.
// You should not change the type of a field. You can change field names as
// these are not used in the encoding.
//
// Tags look like the following.
//
// type mystruct struct {
// A int `plenc:"1"`
// B string `plenc:"-"` // This field is not encoded
// C float64 `plenc:"2"`
// // The values of this field are interned. This reduces allocations if
// // there are a limited set of distinct values used.
// D string `plenc:"3,intern"`
// }
//
// The plenctag tool will add tags to structs for you.
//
// plenc only encodes fields that are exported - ones where the field name
// begins with a capital letter.
//
// Once your structs have plenc tags, encoding and decoding data is very much
// like the standard JSON library using Marshal and Unmarshal calls. The one
// difference is that the Marshal function allows you to append encoded data to
// an existing slice.
//
package plenc