0

go语言go get出错:

D:\workspace\www\go_work\src
λ go get -u github.com/swaggo/gin-swagger
package golang.org/x/text/secure/bidirule: golang.org/x/text is a custom import path for https://go.googlesource.com/text, but D:\workspace\www\go_work\src\golang.org\x\text is checked out from https://github.com/golang/text.git
package golang.org/x/text/unicode/bidi: golang.org/x/text is a custom import path for https://go.googlesource.com/text, but D:\workspace\www\go_work\src\golang.org\x\text is checked out from https://github.com/golang/text.git
package golang.org/x/text/unicode/norm: golang.org/x/text is a custom import path for https://go.googlesource.com/text, but D:\workspace\www\go_work\src\golang.org\x\text is checked out from https://github.com/golang/text.git
package golang.org/x/text/width: golang.org/x/text is a custom import path for https://go.googlesource.com/text, but D:\workspace\www\go_work\src\golang.org\x\text is checked out from https://github.com/golang/text.git

应该怎么做才可以?

cherrylee 1.2k
2018-10-31 提问
4 个回答
1

试试 go mod replace

module example.com/hello

require (
    golang.org/x/text v0.3.0
)

replace (
    golang.org/x/text => github.com/golang/text v0.3.0
)
1

网络不通的情况下的做法:

第一种是去github下载包把text放golang.org/x/下面

第二种是使用包管理工具glide: https://github.com/Mastermind...,改下仓库地址

glide.yaml

package: test
import:
- package: golang.org/x/text
  repo: https://github.com/golang/text
  version: 5cec4b58c438bd98288aeb248bab2c1840713d21
1

推荐去github上把相应的包clone下来:
举例

  1. mkdir $GOPATH/src/golang.org/x
  2. cd $GOPATH/src/golang.org/x && git clone git@github.com:golang/text.git
0

翻墙可以从根上解决问题,并且不会再犯,降低以后的工作量和时间浪费

撰写答案

推广链接