go get: zip for github.com/aliyun/aliyun-oss-go-sdk@v2.0.0 has unexpected file github.com/aliyun/aliyun-oss-go-sdk@v0.0.0-20190618055949-e8251f77f2ba/.travis.yml

如使用 go get 时往往会速度很慢或者压根无法下载下来,如下所示:

E:\go\src\codeBlock>go get github.com/aliyun/aliyun-oss-go-sdk/oss
go: downloading github.com/aliyun/aliyun-oss-go-sdk v2.0.0
go get github.com/aliyun/aliyun-oss-go-sdk/oss: zip for github.com/aliyun/aliyun-oss-go-sdk@v2.0.0 has unexpected file github.com/aliyun/aliyun-oss-go-sdk@v0.0.0-20190618055949-e8251f77f2ba/.travis.yml

先查看版本

go version
go version go1.12.4 linux/amd64

解决方案

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"

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"

或者将以上内容写进 .profile 或者 .bash_profile 文件。

PowerShell (Windows)

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

参考官网教程: https://goproxy.io/

下载完后

运行以下代码:

package main

import (
	"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
posted @ 2021-06-23 14:51  不忘前行  阅读(644)  评论(0编辑  收藏  举报