go generate with splats

265 views
Skip to first unread message

blake.m...@gmail.com

unread,
Apr 1, 2015, 8:22:45 PM4/1/15
to golan...@googlegroups.com
When using `go generate` with a "*" it fails to run the generator. 

$ cat gen.go 
package proto

//go:generate protoc --go_out=plugins=grpc:. *.proto
$ go generate
*.proto: No such file or directory
gen.go:3: running "protoc": exit status 1

When I change the splat to a single, valid filename it works:

$ cat gen.go 
package proto

//go:generate protoc --go_out=plugins=grpc:. back.proto
$ go generate
$ echo $?
0

Has anyone else seen this or see what I'm doing wrong? Any help/guidance would be appreciated.

Rob Pike

unread,
Apr 1, 2015, 8:31:25 PM4/1/15
to blake.m...@gmail.com, golan...@googlegroups.com
The docs are clear that generate parses using go rules, not shell rules. Try

//go:generate sh -c "protoc --go_out=plugins=grpc:. *.proto"

-rob


--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Blake Mizerany

unread,
Apr 1, 2015, 8:52:36 PM4/1/15
to Rob Pike, golan...@googlegroups.com
Rob,

Did you just tell me to RTFM? ;)

Thank you,
Blake
Reply all
Reply to author
Forward
0 new messages