Skip to content

Instantly share code, notes, and snippets.

@meysampg
Last active January 23, 2019 11:40
Show Gist options
  • Save meysampg/9d527786496fb045ff368a327c23d0d2 to your computer and use it in GitHub Desktop.
Save meysampg/9d527786496fb045ff368a327c23d0d2 to your computer and use it in GitHub Desktop.
protobuf_import.md

Dummy Introduction to Protobuf Compile

Import protobuf models into other and compile them

tsjd [To short, just do];

  1. Define go_package option something like:
option go_package = "github.com/meysampg/project_name/pb/folder_name_which_compiled_model_must_be_on_it";
  1. Import package on a .proto file with an address from project root, like
$ cat pb/pb/package/file.proto
syntax = "proto3";

import "pb/another_package/antoher_file.proto";

package file;
  1. Run pb compiler command from the project root:
$ protoc pb/package/file.proto -I. --go_out=plugins=grpc:$GOPATH/src
  1. Now Models will be under pb/folder_name_which_compiled_model_must_be_on_it folder (relative to project root).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment