diff --git a/tools/goctl/rpc/parser/parser.go b/tools/goctl/rpc/parser/parser.go index 1c80a4f2..ad500090 100644 --- a/tools/goctl/rpc/parser/parser.go +++ b/tools/goctl/rpc/parser/parser.go @@ -1,6 +1,7 @@ package parser import ( + "errors" "go/token" "os" "path/filepath" @@ -16,6 +17,8 @@ type ( DefaultProtoParser struct{} ) +var ErrGoPackage = errors.New(`option go_package = "" field is not filled in`) + // NewDefaultProtoParser creates a new instance func NewDefaultProtoParser() *DefaultProtoParser { return &DefaultProtoParser{} @@ -79,6 +82,9 @@ func (p *DefaultProtoParser) Parse(src string, multiple ...bool) (Proto, error) } if len(ret.GoPackage) == 0 { + if ret.Package.Package == nil { + return ret, ErrGoPackage + } ret.GoPackage = ret.Package.Name }