Releases · bufbuild/buf · GitHubA new way of working with Protocol Buffers. Contribute to bufbuild/buf development by creating an account on GitHub.https://github.com/bufbuild/buf/releases
选择版本:
linux 64位版本:
buf-Linux-x86_64.tar.gz
1.2 解压安装wget https://github.com/bufbuild/buf/releases/download/v1.0.0-rc6/buf-Linux-x86_64.tar.gz tar -xvf buf-Linux-x86_64.tar.gz cd buf-Linux-x86_64 pwd
据对路径使用: $pwd/buf -h
1.3 配置/etc/profile 让buf命令全局生效添加以下行到/etc/profile末尾,具体$HOME路径需要自行获取(切记)
export PATH=$PATH:$HOME/buf-Linux-x86_64/bin source /etc/profile
注意命令只会当前终端生效,.buf -h 查看帮助
全局生效,sudo reboot 重启机器
2 protoc安装 2.1 下载地址Releases · protocolbuffers/protobuf · GitHubProtocol Buffers - Google's data interchange format - Releases · protocolbuffers/protobufhttps://github.com/protocolbuffers/protobuf/releases选择版本,protoc-3.19.1-linux-x86_64.zip
2.2 解压安装wget https://github.com/protocolbuffers/protobuf/releases/download/v3.19.1/protoc-3.19.1-linux-x86_64.zip unzip protoc-3.19.1-linux-x86_64.zip cd protoc-3.19.1-linux pwd
2.3 配置/etc/profile安装
添加以下行到/etc/profile末尾,具体$HOME路径需要自行获取(切记)
export PATH=$PATH:$HOME/protoc-3.19.1-linux/bin source /etc/profile
注意命令只会当前终端生效,protoc -h 查看帮助
全局生效,sudo reboot 重启机器
3 golang语言搭建 3.1 protoc 和go 相关插件安装 3.1.1 grpc-go使用git下载grpc-go源代码,并安装protoc-gen-go-grpc
git clone https://github.com/grpc/grpc-go.git cd grpc-go/cmd/protoc-gen-go-grpc/ go build go install which protoc-gen-go-grpc
3.1.2 go proto 安装
go install github.com/golang/protobuf/protoc-gen-go which protoc-gen-go3.2 编译生成go代码 3.2.1 下载buf-tour示例代码
git clone https://github.com/bufbuild/buf-tour
注意检查go工程代码目录有配置文件
buf.yaml
buf.gen.yaml
3.2.2 生成代码cd buf-tour buf generate
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)