From 85c3ca1013d7c1214a926b0029874ba89dd976d4 Mon Sep 17 00:00:00 2001 From: Solly Ross Date: Mon, 15 May 2017 19:01:23 -0400 Subject: [PATCH] [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. --- cmd/libs/go2idl/go-to-protobuf/protobuf/generator.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/libs/go2idl/go-to-protobuf/protobuf/generator.go b/cmd/libs/go2idl/go-to-protobuf/protobuf/generator.go index 5e3ed2efe40..ed826b9c3be 100644 --- a/cmd/libs/go2idl/go-to-protobuf/protobuf/generator.go +++ b/cmd/libs/go2idl/go-to-protobuf/protobuf/generator.go @@ -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]) } }