goprotobuf: Changes for new struct tag format.
Protocol messages have changed their struct tags from
"PB(...)"
to
`protobuf:"..."`
The format represented by "..." is unchanged.
Regenerate {descriptor,plugin}.pb.go files at the same time.
R=r, rsc
CC=golang-dev
http://codereview.appspot.com/4654077
diff --git a/compiler/generator/generator.go b/compiler/generator/generator.go
index 884fef1..b902a1d 100644
--- a/compiler/generator/generator.go
+++ b/compiler/generator/generator.go
@@ -359,7 +359,7 @@
// It then sets file name mappings defined by those entries.
func (g *Generator) CommandLineParameters(parameter string) {
g.Param = make(map[string]string)
- for _, p := range strings.Split(parameter, ",", -1) {
+ for _, p := range strings.Split(parameter, ",") {
if i := strings.Index(p, "="); i < 0 {
g.Param[p] = ""
} else {
@@ -847,7 +847,7 @@
g.P()
}
-// The tag is a string like "PB(varint,2,opt,name=fieldname,def=7)" that
+// The tag is a string like "varint,2,opt,name=fieldname,def=7" that
// identifies details of the field for the protocol buffer marshaling and unmarshaling
// code. The fields are:
// wire encoding
@@ -921,7 +921,7 @@
} else {
name = ",name=" + name
}
- return Quote(fmt.Sprintf("PB(%s,%d,%s%s%s%s%s)",
+ return Quote(fmt.Sprintf("%s,%d,%s%s%s%s%s",
wiretype,
proto.GetInt32(field.Number),
optrepreq,
@@ -1030,7 +1030,7 @@
for _, field := range message.Field {
fieldname := CamelCase(*field.Name)
typename, wiretype := g.GoType(message, field)
- tag := g.goTag(field, wiretype)
+ tag := "`protobuf:" + g.goTag(field, wiretype) + "`"
g.P(fieldname, "\t", typename, "\t", tag)
g.RecordTypeUse(proto.GetString(field.TypeName))
}