go语言go get出错

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

应该怎么做才可以?

阅读 7.6k
6 个回答

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

试试 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
)

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

第一种是去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

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

  1. mkdir $GOPATH/src/golang.org/x
  2. cd $GOPATH/src/golang.org/x && git clone git@github.com:golang/text.git
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题