Golang Installing and using protobuf under Windows

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed.

Installation section

1. Install the Go package under Windows, download the address Http://www.golangtc.com/download


2. Set the GOPATH environment variable, the PROTOBUF obtained from GitHub will be downloaded to the Gopath directory


3. Install the GIT package, https://git-scm.com/downloads/


4. Add the path of the GIT.exe in the path variable D:\Program files\git\bin (choose the path you installed yourself)


5. Run the git and go commands separately in CMD to see if you can identify the two commands, and if not, you should have missed a step in 1-4.


6. Run separately

Go get-u Github.com/golang/protobuf/proto

go get-u github.com/golang/protobuf/protoc-gen-go

Installing the PROTOBUF Library


7. Download Protoc.exe,proto tools to generate. Go Files https://github.com/google/protobuf/releases


8. Run the command d:\protofile\bin\protoc.exe--plugin=protoc-gen-go=%gopath%\bin\protoc-gen-go.exe--go_out=././gate.proto To generate a Gate.pb.go source file

D:\protofile\bin\protoc.exe is the path where Protoc.exe is located.

--plugin=protoc-gen-go=%gopath%\bin\protoc-gen-go.exe indicates the path where the Protoc-gen-go.exe is located, and if there is no line, you will be prompted to Protoc-gen-go

--go_out=././gate.proto says according to./gate.proto in./Location Go type file

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.