当前位置: 首页 > 工具软件 > Go + HTTP/2 > 使用案例 >

【GO】go安装protobuf、proto、grpc、报错(go get: module github.com/golang/protobuf/proto: Get )

阎修杰
2023-12-01

cmd运行

go get -v -u github.com/golang/protobuf/proto@v1.3.2

报错:

C:\Users\admin>go get -v -u github.com/golang/protobuf/proto@v1.3.2
go get: module github.com/golang/protobuf/proto: Get "https://proxy.golang.org/github.com/golang/protobuf/proto/@v/list": dial tcp 142.251.43.17:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

通过各种尝试,执行以下两条命令后,再次执行go get可顺利安装

go env -w GO111MODULE=on

go env -w GOPROXY=https://goproxy.cn,direct

再次执行:

C:\Users\admin>go get -v -u github.com/golang/protobuf/proto@v1.3.2
go: module github.com/golang/protobuf is deprecated: Use the "google.golang.org/protobuf" module instead.

在目录下执行
C:\Users\admin\go\pkg\mod\github.com\golang\protobuf@v1.3.2\protoc-gen-go
cmd:
go build

获得:protoc-gen-go.exe
放到:D:\Program Files (x86)\Protobuf\bin 目录protoc-gen-go.exe

在go.mod添加require github.com/golang/protobuf v1.3.2

module 02work

go 1.17

require github.com/golang/protobuf v1.3.2
 类似资料: