https://github.com/stepanstipl/go-protobuf-import-example
Importing protobuf definitions with Go modules
https://github.com/stepanstipl/go-protobuf-import-example
go golang grpc protobuf
Last synced: about 1 year ago
JSON representation
Importing protobuf definitions with Go modules
- Host: GitHub
- URL: https://github.com/stepanstipl/go-protobuf-import-example
- Owner: stepanstipl
- Created: 2019-09-09T19:18:43.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2022-08-31T23:08:30.000Z (almost 4 years ago)
- Last Synced: 2025-03-18T20:08:32.871Z (over 1 year ago)
- Topics: go, golang, grpc, protobuf
- Language: Go
- Homepage: https://stepan.wtf/importing-protobuf-with-go-modules/
- Size: 17.6 KB
- Stars: 19
- Watchers: 2
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# go-protobuf-import-example
Example of how to import versioned protobuf definitions from Go packages when
using Go modules.
This code is to accompany my blog post [Importing protobuf definitions with Go
modules](https://stepan.wtf/importing-protobuf-with-go-modules/), please read
for more details.
## TL;DR
Symlink directories of individual modules (obtained from `go list`) under one
folder, or populate `vendor` directory by running `go mod vendor`. Paths within
that directory then match relative import paths used in protobuf `import`
statement and you can run `protoc` with `-I ./vendor` flag.
## Requirements
- `protoc`- https://github.com/protocolbuffers/protobuf
- `gogo/protobuf` - https://github.com/gogo/protobuf
- `go` v1.12+ - https://golang.org/
## Usage
Run `make` for help:
```console
$ make
help Print list of tasks
build Build go project
proto-link Generate go protobuf files using symlinked modules
proto-vendor Generate go protobuf files using go mode vendor
run Runs the demo server
```