Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 proto-gae | |
| 2 ========= | |
| 3 | |
| 4 proto-gae is a simple `go generate`-compatible tool for generating | |
| 5 "github.com/luci/gae/service/datastore".PropertyConverter implementation for | |
| 6 `protoc`-generated message types. This allows you to embed proto.Message | |
|
dnj
2016/01/23 06:15:36
nit: Back-ticks around proto.Message
iannucci
2016/01/23 10:01:07
Done.
| |
| 7 implementations into your datastore models. | |
| 8 | |
| 9 The generated implementations serialize to/from the binary protobuf format into | |
| 10 an unindexed []byte property. | |
| 11 | |
| 12 | |
| 13 Example | |
| 14 ------- | |
| 15 | |
| 16 #### path/to/mything/protos/mything.proto | |
| 17 ```protobuf | |
| 18 syntax = "proto3"; | |
| 19 package protos; | |
| 20 message MyProtoThing { | |
| 21 my string = 1; | |
| 22 proto int64 = 1; | |
| 23 thing float = 1; | |
| 24 } | |
| 25 ``` | |
| 26 | |
| 27 #### path/to/mything/protos/gen.go | |
| 28 ```go | |
| 29 package protos | |
| 30 // assume github.com/luci/luci-go/tools/cmd/cproto is in $PATH. Try it, it's | |
| 31 // awesome :). | |
| 32 | |
| 33 //go:generate cproto | |
| 34 //go:generate proto-gae -type MyProtoThing | |
| 35 ``` | |
| 36 | |
| 37 #### path/to/mything/thing.go | |
| 38 ```go | |
| 39 package mything | |
| 40 | |
| 41 import "path/to/package/protos" | |
| 42 | |
| 43 type DatastoreModel struct { | |
| 44 // This will now 'just work'; ProtoMessage will round-trip to datastore as | |
| 45 // []byte. | |
| 46 ProtoMessage protos.MyProtoThing | |
| 47 } | |
| 48 ``` | |
| OLD | NEW |