deft_code
deft_code

Reputation: 59337

Protobuf compilation with Go tools

Is there a good way to integrate protobuf compiles with the go build command?

Upvotes: 3

Views: 988

Answers (1)

Intermernet
Intermernet

Reputation: 19418

goprotobuf "provides Go support, in the form of a library and protocol compiler plugin, for Google's protocol buffers".

The README at the goprotobuf library has some good info.

From https://code.google.com/p/goprotobuf/source/browse/README#106 :

Consider file test.proto, containing

    package example;

    enum FOO { X = 17; };

    message Test {
      required string label = 1;
      optional int32 type = 2 [default=77];
      repeated int64 reps = 3;
      optional group OptionalGroup = 4 {
        required string RequiredField = 5;
      }
    }

To build a package from test.proto and some other Go files, write a Makefile like this:

    include $(GOROOT)/src/Make.$(GOARCH)

    TARG=path/to/example
    GOFILES=\
        test.pb.go\
        other.go

    include $(GOROOT)/src/Make.pkg
    include $(GOROOT)/src/pkg/code.google.com/p/goprotobuf/Make.protobuf

Upvotes: 2

Related Questions