I have added two new features jsontag and moretags to allow you to modify the generated tags so as to better integrate with other serializers that use reflect.
I have added a new feature jsontag, which is in alpha since I only have one test.
This allows you to change the value of the json tag.
See this example
https://code.google.com/p/gogoprotobuf/source/browse/test/tags/tags.protoTypically the jsontag is generated as the fieldname.
Lets show another example:
message A {
optional string Field1 = 1;
}
will generate
type A struct {
Field1 string `protobuf:"bytes,1,opt" json:"Field1"`
}
Lets see what happens if we use the jsontag extension
message A {
optional string Field1 = 1 [(gogoproto.jsontag) = "MyField1"];
}
Now our generated code looks like this
type A struct {
Field1 string `protobuf:"bytes,1,opt" json:"MyField1"`
}
The other new feature moretags is experimental, since I only have one test and I am not sure what developers will want the behaviour of XXX_recognized and XXX_extensions to be.
Basically moretags allows you to add more tags to the end of the tag.
message A {
optional string Field1 = 1 [(gogoproto.moretags) = "xml:\",comment\""];
}
This generates extra tags like so
type A struct {
Field1 string `protobuf:"bytes,1,opt" json:"Field1" xml:",comment"`
}
Enjoy.
I hope you find these useful.