通过go get安装各种工具时提示报错

go get -u github.com/golang/protobuf/proto

报错信息:

go get: module github.com/golang/protobuf/proto: Get "https://proxy.golang.org/github.com/golang/protobuf/proto/@v/list": dial tcp 216.58.200.49: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可顺利安装

  1. go env -w GO111MODULE=on

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

 再次执行:

PS D:\GO> go get -u github.com/golang/protobuf/proto
go: downloading github.com/golang/protobuf v1.5.2
go: downloading google.golang.org/protobuf v1.26.0
go: downloading google.golang.org/protobuf v1.27.1

 安装成功