protoc-gen-gotemplate
protoc-gen-gotemplate copied to clipboard
Panic: can't evaluate field GoPkg in type *descriptor.File
Following example in examples/single-package-mode/templates/service.go.tmpl
leads to a panic:
Template:
{{$currentFile := $file.Name | getProtoFile}}
{{- range .Service.Method}}
{{- $in := .InputType | getMessageType $file}}
{{- $out := .OutputType | getMessageType $file}}
{{$in.GoType $currentFile.GoPkg.Path}} <-- panics
{{- end}} {{/*range **Method*/}}
Output:
panic: template: rpc.go.tmpl:50:34: executing "rpc.go.tmpl" at <$currentFile.GoPkg.P...>: can't evaluate field GoPkg in type *descriptor.File
goroutine 1 [running]:
main.(*GenericTemplateBasedEncoder).Files(0xc00009d8b0, 0x14, 0xc000029180, 0xc000184000)
~/go/src/moul.io/protoc-gen-gotemplate/encoder.go:213 +0x4df
main.main()
~/go/src/moul.io/protoc-gen-gotemplate/main.go:130 +0x411
--gotemplate_out: protoc-gen-gotemplate: Plugin failed with status code 2.
Has the return type of getProtoFile
changed? Or is there an error in the template?
I think this is where you want to look for the methods available. https://godoc.org/google.golang.org/protobuf/types/descriptorpb