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