master
guonaihong 2 years ago committed by GitHub
parent 1aebb3e5e4
commit 1fd0c3992b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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
}

Loading…
Cancel
Save