Build Goprotobuf under Linux

Source: Internet
Author: User
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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.