go 安装 protobuf proto3

xiaoxiao2021-02-28  114

安装环境:ubuntu 16.04

1.查看当前go的环境变量:go env

2.go get github.com/golang/protobuf/protoc-gen-go 会下载protoc-gen-go到 GOPATH/bin PATH,它只是protobuf3的golang插件,不是真正的编译器

3.下载protoc,地址https://github.com/google/protobuf/releases,里面可以找到win/linux/mac的二进制文件, 找到和下载解压protoc-3.1.0-linux-x86_64.zip,把里面的protoc拷贝到PATH下面

4.生成golang的代码 (备注:只有golang需要插件,其它语言不需要) 比如当前目录已经存在helloword.proto文件; 生成对于的golang代码命令:protoc –go_out=. helloword.proto

其他: proto3文档:https://developers.google.com/protocol-buffers/docs/proto3 go api文档:https://godoc.org/github.com/golang/protobuf/proto https://github.com/google/protobuf/blob/master/examples/addressbook.proto

转载请注明原文地址: https://www.6miu.com/read-83736.html

最新回复(0)