是否有一种将protobuf编译与go build命令集成的好方法?
发布于 2013-06-25 13:53:21
古原布夫“以库和协议编译器插件的形式为谷歌的协议缓冲区提供Go支持”。
来自https://code.google.com/p/goprotobuf/source/browse/README#106:
考虑文件test.proto,包含
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;
}
}要从test.proto和其他Go文件构建包,请编写如下所示的Makefile:
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.protobufhttps://stackoverflow.com/questions/17287087
复制相似问题