Documentation
¶
Index ¶
- Variables
- func BuildProtoPackageMap(importedProtos []ImportedProto) map[string]ImportedProto
- func CamelCase(s string) string
- func GetComment(comment *proto.Comment) string
- func GoSanitized(s string) string
- func ResolveImports(src string, protoPaths []string) ([]string, error)
- type DefaultProtoParser
- type Import
- type ImportedProto
- type Message
- type Option
- type Package
- type Proto
- type RPC
- type Service
- type Services
Constants ¶
This section is empty.
Variables ¶
var ErrGoPackage = errors.New(`option go_package = "" field is not filled in`)
Functions ¶
func BuildProtoPackageMap ¶ added in v1.10.1
func BuildProtoPackageMap(importedProtos []ImportedProto) map[string]ImportedProto
BuildProtoPackageMap returns a map from proto package name to ImportedProto, enabling O(1) lookup of Go package info given a proto type qualifier like "ext".
func CamelCase ¶
CamelCase copy from protobuf, for more information, please see github.com/golang/protobuf@v1.4.2/protoc-gen-go/generator/generator.go:2648
func GetComment ¶
GetComment returns content with prefix //
func GoSanitized ¶
GoSanitized copy from protobuf, for more information, please see google.golang.org/protobuf@v1.25.0/internal/strs/strings.go:71
func ResolveImports ¶ added in v1.10.1
ResolveImports returns the absolute paths of all transitively imported proto files reachable from src, excluding well-known types (google/*). It searches for imported files in protoPaths (equivalent to protoc -I flags). Files that cannot be found in protoPaths are silently skipped so that system-level or well-known protos do not cause errors.
Types ¶
type DefaultProtoParser ¶
type DefaultProtoParser struct{}
DefaultProtoParser types an empty struct
func NewDefaultProtoParser ¶
func NewDefaultProtoParser() *DefaultProtoParser
NewDefaultProtoParser creates a new instance
type ImportedProto ¶ added in v1.10.1
type ImportedProto struct {
// Src is the absolute path to the proto file.
Src string
// ProtoPackage is the value of the proto "package" declaration.
// It is the qualifier used in dotted type references, e.g. "ext" in "ext.ExtReq".
ProtoPackage string
// GoPackage is the value of the option go_package field, or the proto
// package name when go_package is absent.
GoPackage string
// PbPackage is the sanitized Go package name derived from GoPackage.
PbPackage string
}
ImportedProto holds the package information of a transitively imported proto file.
func ParseImportedProtos ¶ added in v1.10.1
func ParseImportedProtos(src string, protoPaths []string) ([]ImportedProto, error)
ParseImportedProtos resolves and parses all transitively imported proto files, returning their package information for use in code generation.
type Proto ¶
type Proto struct {
Src string
Name string
Package Package
PbPackage string
GoPackage string
Import []Import
Message []Message
Service Services
// ImportedProtos holds the metadata for all transitively imported proto files.
// Populated by the generator before code generation.
ImportedProtos []ImportedProto
}
Proto describes a proto file,