Skip to content

Instantly share code, notes, and snippets.

@jmhodges
Last active August 14, 2023 13:24
Show Gist options
  • Star 15 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jmhodges/a50ab84b13c2cd791571 to your computer and use it in GitHub Desktop.
Save jmhodges/a50ab84b13c2cd791571 to your computer and use it in GitHub Desktop.
Generating protobuf Go files with `go generate` and a vendored protobuf package (specifically, vendored with godep).
//go:generate protoc --go_out=import_prefix=github.com/your_github_acct/your_repo/Godeps/_workspace/src/:. your_proto_file.proto
package yourprotopkg
$ pwd
/home/your_acct/src/github.com/your_github_acct/your_repo/
$ ls
Godeps doc.go your_proto_file.proto
$ go generate . # or `go generate github.com/your_github_acct/your_repo/`
$ ls
Godeps doc.go your_proto_file.pb.go your_proto_file.proto
$ grep "import proto" ./your_proto_file.pb.go
import proto "github.com/your_github_acct/your_repo/Godeps/_workspace/src/github.com/golang/protobuf/proto"
@jmhodges
Copy link
Author

jmhodges commented Sep 5, 2015

With this, no more futzing with godep save -r every time you regenerate your protobufs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment