Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panic: can't evaluate field GoPkg in type *descriptor.File #128

Open
piotrekmonko opened this issue Oct 3, 2018 · 1 comment
Open

Panic: can't evaluate field GoPkg in type *descriptor.File #128

piotrekmonko opened this issue Oct 3, 2018 · 1 comment

Comments

@piotrekmonko
Copy link
Contributor

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?

@zachfi
Copy link

zachfi commented Jun 13, 2020

I think this is where you want to look for the methods available.
https://godoc.org/google.golang.org/protobuf/types/descriptorpb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants