moul / protoc-gen-gotemplate

:open_file_folder: generic protocol generator based on golang's text/template (grpc/protobuf)
https://manfred.life/protoc-gen-gotemplate
MIT License
438 stars 68 forks source link

Nothing happens #158

Open domgolonka opened 4 years ago

domgolonka commented 4 years ago
$ ls templates/
enum.txt.tmpl
$ cat templates/enum.txt.tmpl 
This is static text
$ protoc -I. -I=../declarations/postmark-sender --gotemplate_out=debug=true:./test/ ../declarations/postmark-sender/postmark.proto
WARNING: Package "github.com/golang/protobuf/protoc-gen-go/generator" is deprecated.
    A future release of golang/protobuf will delete this package,
    which has long been excluded from the compatibility promise.

$ ls test/

I also tried to put the template directory in: $ protoc -I. -I=../declarations/postmark-sender --gotemplate_out=template_dir=templates,debug=true:test ../declarations/postmark-sender/*.proto WARNING: Package "github.com/golang/protobuf/protoc-gen-go/generator" is deprecated. A future release of golang/protobuf will delete this package, which has long been excluded from the compatibility promise.

$ ls test/

I also tried to put the template directory and output directory in:

$ protoc -I=../declarations/postmark-sender --gotemplate_out=template_dir=templates,debug=true,destination_dir=./test/:test ../declarations/postmark-sender/*.proto
WARNING: Package "github.com/golang/protobuf/protoc-gen-go/generator" is deprecated.
    A future release of golang/protobuf will delete this package,
    which has long been excluded from the compatibility promise.

$ ls test

moul commented 4 years ago

Hi @domgolonka,

Your usage is correct, I think this is due to a conflict with another package, can you send me the version of various deps: protoc, protoc-gen-go

How did you install protoc-gen-gotemplate?

domgolonka commented 4 years ago

$ protoc --version libprotoc 3.12.3

I did these to install it. I had proto and proto- go get -u github.com/golang/protobuf/{proto,protoc-gen-go} go get -u moul.io/protoc-gen-gotemplate

tgorton617 commented 3 years ago

Old issue but adding my experience for others:

I encountered a similar problem and realized that by default protoc-gen-gotemplate does not process .proto files that don't contain a service -- I resolved this by adding the "all=true" option as shown in the README. If your .proto file doesn't contain a service, this is probably what's going on.