guonaihong %!s(int64=2) %!d(string=hai) anos
pai
achega
1fd0c3992b
Modificáronse 1 ficheiros con 6 adicións e 0 borrados
  1. 6 0
      tools/goctl/rpc/parser/parser.go

+ 6 - 0
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
 	}