[go-to-protobuf] Quote tag cast{key,value,type}

When using a `cast{key,value,type}` that was injected via struct tag, we
need to make sure to quote the value when transfering it over to proto
tags.  Otherwise, it'll come through as unquoted, resulting in invalid
proto.

This was previously not a problem, since all values of `castkey` and
`casttype` were actually coming from the auto-injecting code which deals
with maps and aliases, which does correctly quote values.
This commit is contained in:
Solly Ross 2017-05-15 19:01:23 -04:00
parent 7b8e572d8a
commit 85c3ca1013

View File

@ -598,7 +598,7 @@ func protobufTagToField(tag string, field *protoField, m types.Member, t *types.
protoExtra[parts[0]] = parts[1]
case "casttype", "castkey", "castvalue":
parts[0] = fmt.Sprintf("(gogoproto.%s)", parts[0])
protoExtra[parts[0]] = parts[1]
protoExtra[parts[0]] = strconv.Quote(parts[1])
}
}