diff --git a/patch/field_type.go b/patch/field_type.go index 8e3dad6..9917ccf 100644 --- a/patch/field_type.go +++ b/patch/field_type.go @@ -43,6 +43,11 @@ func (p *Patcher) patchTypeDef(id *ast.Ident, obj types.Object) { return true } return false + case *ast.StarExpr: + t.X = &ast.Ident{ + Name: fieldType, + } + return true default: return false } diff --git a/patch/patcher.go b/patch/patcher.go index 026bf91..c51e70f 100644 --- a/patch/patcher.go +++ b/patch/patcher.go @@ -320,7 +320,7 @@ func (p *Patcher) scanField(f *protogen.Field) { switch { case f.Message != nil && !f.Desc.IsList(): log.Printf("Warning: type declared for message field: %s", f.Desc.Name()) - case f.Oneof != nil: + case f.Oneof != nil && !f.Desc.HasOptionalKeyword(): p.Type(ident.WithChild(f.GoIdent, f.GoName), fieldType) p.Type(ident.WithChild(m.GoIdent, "Get"+f.GoName), fieldType) default: