36

Go 语言解决不能Go get安装Gin问题解决方案 | 梦遥奇缘

 4 years ago
source link: https://www.idiot6.com/2019/07/23/go-gin-golang-x/?
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Go 语言解决不能Go get安装Gin问题解决方案

1 Comment

1.问题描述

Go get 出现超时问题:“golang unrecognized import path "golang.org/x/net unrecognized import path "golang.org/x/sys" Unknown SSL protocol error in connection to gopkg.in:443 "”

2.解决办法

  • 网络上解决方案1手动下载:
    mkdir $GOPATH/src/golang.org/x
    cd $GOPATH/src/golang.org/x
    git clone [email protected]:golang/text.git

方案二:设置代理

3.最佳解决方案

  • 从 Go 1.11 版本开始已经开始支持Go Mod ,并且提供了包下载的解决方案,就是使用 https://goproxy.io/ 直接代理下载,官方设置方法:

  • macos/linux

export GO111MODULE=on
export GOPROXY=https://goproxy.io
  • Wins 使用PowerShell 设置(这里输入是去当前设置的GOPATH)
$env:GO111MODULE="on"
$env:GOPROXY="https://goproxy.io"

go-gin-golang
go-gin-golang
  • 提示这里需要加入引号,否则会报on或地址有问题,之后在执行Go get 等其他命令都一帆风顺了。

Notice: 如果你使用的Go version 》=1.13 请使用

go env -w GOPROXY=https://goproxy.io,direct
go env -w GOPRIVATE=*.corp.example.com

Go 成功安装Gin框架并使用Go mod管理

安装Gin框架并使用Go
安装Gin框架并使用Go

参考资料:
https://goproxy.io/
一键解决 go get golang.org/x 包失败

分享到


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK