先下載最新版的golang安裝程序相速;
設(shè)置好GOPATH碟渺,把%GOPATH%/bin 添加到環(huán)境變量;
打開?https://github.com/protocolbuffers/protobuf/releases/
下載如下的工具突诬,解壓苫拍,把protoc.exe路徑添加到環(huán)境變量
命令行執(zhí)行
go get github.com/golang/protobuf
在%GOPATH%/src/github.com/golang/protobuf 目錄下,
go build
go install
會在%GOPATH%/bin下生成protoc-gen-go.exe
測試
編寫 person.proto
syntax = "proto2";message Person {
? ? required int32 id = 1;
? ? optional string name = 2;
}
protoc --go_out=. person.proto
生成person.pb.go即ok了旺隙!