日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 人文社科 > 生活经验 >内容正文

生活经验

go get 无法下载问题解决方案及下载 aliyun-oss-go-sdk incompatible.info

發(fā)布時(shí)間:2023/11/27 生活经验 48 豆豆
生活随笔 收集整理的這篇文章主要介紹了 go get 无法下载问题解决方案及下载 aliyun-oss-go-sdk incompatible.info 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

1. 問題現(xiàn)象

由于眾所周知的原因,使用 go get 時(shí)往往會速度很慢或者壓根無法下載下來,如下所示:

wohu@wohu:/$ go get -v github.com/aliyun/aliyun-oss-go-sdk/oss
github.com/aliyun/aliyun-oss-go-sdk (download)
Fetching https://golang.org/x/time/rate?go-get=1
https fetch failed: Get https://golang.org/x/time/rate?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
package golang.org/x/time/rate: unrecognized import path "golang.org/x/time/rate" (https fetch: Get https://golang.org/x/time/rate?go-get=1: dial tcp 216.239.37.1:443: i/o timeout)wohu@wohu:/$ go version
go version go1.12.4 linux/amd64

一直提示超時(shí),無法下載安裝。

2. 解決方案

2.1 Go version >= 1.13 (RECOMMENDED)

go env -w GO111MODULE=on
go env -w GOPROXY="https://goproxy.io,direct"# Set environment variable allow bypassing the proxy for selected modules (optional)
go env -w GOPRIVATE="*.corp.example.com"# Set environment variable allow bypassing the proxy for specified organizations (optional)
go env -w GOPRIVATE="example.com/org_name"

2.2 Go version <= 1.12

  • Bash (Linux or macOS)
# Enable the go modules feature
export GO111MODULE="on"
# Set the GOPROXY environment variable
export GOPROXY="https://goproxy.io"

或者將以上內(nèi)容寫進(jìn) .profile 或者 .bash_profile 文件。

  • PowerShell (Windows)
# Enable the go modules feature
$env:GO111MODULE="on"
# Set the GOPROXY environment variable
$env:GOPROXY="https://goproxy.io"

參考官網(wǎng)教程: https://goproxy.io/

2.3 下載源碼

https://blog.csdn.net/u013536232/article/details/104476356

3. 使用示例

我們以 aliyun-oss-go-sdk 為例,使用步驟 2 中的解決方案后,下載安裝過程如下:

wohu@wohu:/$ export GO111MODULE="on"
wohu@wohu:/$ export GOPROXY="https://goproxy.io"
wohu@wohu:/$ go get -v github.com/aliyun/aliyun-oss-go-sdk/oss
Fetching https://goproxy.io/github.com/aliyun/aliyun-oss-go-sdk/oss/@v/list
Fetching https://goproxy.io/github.com/aliyun/aliyun-oss-go-sdk/@v/list
go: finding github.com/aliyun/aliyun-oss-go-sdk v2.1.2+incompatible
Fetching https://goproxy.io/github.com/aliyun/aliyun-oss-go-sdk/@v/v2.1.2+incompatible.info
go: downloading github.com/aliyun/aliyun-oss-go-sdk v2.1.2+incompatible
Fetching https://goproxy.io/github.com/aliyun/aliyun-oss-go-sdk/@v/v2.1.2+incompatible.zip
go: extracting github.com/aliyun/aliyun-oss-go-sdk v2.1.2+incompatible
Fetching https://goproxy.io/github.com/aliyun/aliyun-oss-go-sdk/@v/v2.1.2+incompatible.mod
Fetching https://goproxy.io/golang.org/x/time/rate/@v/list
Fetching https://goproxy.io/golang.org/x/time/@v/list
go: finding golang.org/x/time latest
Fetching https://goproxy.io/golang.org/x/time/@latest
go: downloading golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e
Fetching https://goproxy.io/golang.org/x/time/@v/v0.0.0-20200630173020-3af7569d3a1e.zip
go: extracting golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e
Fetching https://goproxy.io/golang.org/x/time/@v/v0.0.0-20200630173020-3af7569d3a1e.mod
golang.org/x/time/rate
github.com/aliyun/aliyun-oss-go-sdk/oss
wohu@wohu:/$ 

下載完成后將 pkg 目錄下的 aliyun-oss-go-sdk 拷貝到 $GOPATH/src/github.com

運(yùn)行以下代碼:

package mainimport ("fmt""github.com/aliyun/aliyun-oss-go-sdk/oss"
)func main() {fmt.Println("OSS Go SDK Version: ", oss.Version)
}

輸出:

OSS Go SDK Version:  v2.1.2

總結(jié)

以上是生活随笔為你收集整理的go get 无法下载问题解决方案及下载 aliyun-oss-go-sdk incompatible.info的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。