Fix protobuf generator for aliases to repeated types

pull/6/head
Michal Fojtik 2017-11-07 10:24:04 +01:00
parent 3b4424ce8c
commit 0a9c42525b
No known key found for this signature in database
GPG Key ID: 172B61E538AAC0EE
1 changed files with 6 additions and 3 deletions

View File

@ -513,11 +513,14 @@ func memberTypeToProtobufField(locator ProtobufLocator, field *protoField, t *ty
log.Printf("failed to alias: %s %s: err %v", t.Name, t.Underlying.Name, err)
return err
}
// If this is not an alias to a slice, cast to the alias
if !field.Repeated {
if field.Extras == nil {
field.Extras = make(map[string]string)
}
field.Extras["(gogoproto.casttype)"] = strconv.Quote(locator.CastTypeName(t.Name))
}
}
case types.Slice:
if t.Elem.Name.Name == "byte" && len(t.Elem.Name.Package) == 0 {
field.Type = &types.Type{Name: types.Name{Name: "bytes"}, Kind: types.Protobuf}