Skip to content
Importing protobuf definitions with Go modules
Go Makefile Shell
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
pb Use gogoprotobuf to match imported definiton Sep 10, 2019
.gitignore Initial commit Sep 9, 2019
Makefile Use gogoprotobuf to match imported definiton Sep 10, 2019
README.md Initial commit Sep 9, 2019
go.mod Initial commit Sep 9, 2019
go.sum Initial commit Sep 9, 2019
main.go go fmt run Sep 9, 2019
my.proto Initial commit Sep 9, 2019
protobuf-import.sh Initial commit Sep 9, 2019

README.md

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, 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

Usage

Run make for help:

$ 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
You can’t perform that action at this time.