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