This is a creation in Article, where the information may have evolved or changed.
build goprotobuf under Linux
1. Build the Go Language environment
Reference official website: Http://golang.org/doc/install The
main thing is to set the Go_path this variable, this is your working environment directory, you can use Go env to query the settings OK.
2. Build PROTOBUF Environment
This can refer to my blog: http://blog.csdn.net/chdhust/article/details/38729161
3. Build Goprotobuf
Go get code.google.com/p/goprotobuf/{proto,protoc-gen-go}
Go install Code.google.com/p/goprotobuf/proto
Then can find in the $GO _path/bin protoc-gen-go This program, then can be practical protoc-gen-go to GO language proto file automatic generation.
go1.0 using: protoc-gen-go--go_out=. Hellowrold.proto
go1.1 Direct Utility The following commands
Protoc--go_out=. Hellowrold.proto
Proto file:
Package LM;
Message HelloWorld
{
Required Int32 id =1;//ID
Requiredstringstr =2;//Str
Optional int32 opt =3;//Optional Field
}
Note: Package LM; Therefore must be placed in the LM directory (refer to the proto specification), use the command to generate files under LM
Protoc--go_out=. Hellowrold.proto