如何调试挂起的 Golang “go get” 调用?

huangapple go评论78阅读模式
英文:

How to debug a hanging golang "go get" call?

问题

go get -v gopkg.in/urfave/cli.v2在打印以下输出后挂起了。尽管我可以安装其他包,但是如何调试此问题的根本原因呢?

这个命令已经挂起超过6个小时了。我不得不通过按下Ctrl+C来退出。

$ go get -v -insecure gopkg.in/urfave/cli.v2
Fetching https://gopkg.in/urfave/cli.v2?go-get=1
Parsing meta tags from https://gopkg.in/urfave/cli.v2?go-get=1 (status code 200)
get "gopkg.in/urfave/cli.v2": found meta tag main.metaImport{Prefix:"gopkg.in/urfave/cli.v2", VCS:"git", RepoRoot:"https://gopkg.in/urfave/cli.v2"} at https://gopkg.in/urfave/cli.v2?go-get=1
gopkg.in/urfave/cli.v2 (download)

请问如何调试这个问题的根本原因?

英文:

The go get -v gopkg.in/urfave/cli.v2 is hanging after printing the following output. I could install other packages though. How to debug the root cause for this?

This has been hanging for over 6 hours. Had to come out of this by pressing cntrl+c.

$go get -v -insecure gopkg.in/urfave/cli.v2
Fetching https://gopkg.in/urfave/cli.v2?go-get=1
Parsing meta tags from https://gopkg.in/urfave/cli.v2?go-get=1 (status code 200)
get "gopkg.in/urfave/cli.v2": found meta tag main.metaImport{Prefix:"gopkg.in/urfave/cli.v2", VCS:"git", RepoRoot:"https://gopkg.in/urfave/cli.v2"} at https://gopkg.in/urfave/cli.v2?go-get=1
gopkg.in/urfave/cli.v2 (download)

答案1

得分: 2

很可能是网络问题。当与我们的ISP连接出现数据包丢失时,我们就会出现这种现象。

由于go get使用git,你可以手动克隆存储库并查看git给出的信息:

$ git clone --verbose https://gopkg.in/urfave/cli.v2
英文:

Most likely a networking issue. We had this phenomenon while the connection to our ISP experienced package loss.

Since go get uses git, you could manually clone the repository and see what git tells you:

$ git clone --verbose https://gopkg.in/urfave/cli.v2

答案2

得分: 2

回答实际问题(只是因为它是我今天搜索的热门结果),调试信息是通过**-x**标志打印的:

go get -x <module>
英文:

Answering the actual question (just because it's a top hit for my search today) the debugging info is printed with -x flag:

go get -x &lt;module&gt;

答案3

得分: 0

原来在https://gopkg.in/urfave/cli.v2上没有源代码仓库。我不得不按照@Louis的建议自己克隆仓库。

mkdir -p $GOPATH/src/gopkg.in/urfave
cd $GOPATH/src/gopkg.in/urfave
git clone https://github.com/urfave/cli -b v2 cli.v2

注意:我已经为作者打开了一个问题https://github.com/urfave/cli/issues/591。

英文:

It turns out there is no source code repo at https://gopkg.in/urfave/cli.v2. I had to follow @Louis suggestion of cloning the repo myself

mkdir -p $GOPATH/src/gopkg.in/urfave
cd $GOPATH/src/gopkg.in/urfave
git clone https://github.com/urfave/cli -b v2 cli.v2

NOTE: Opened an issue for the author https://github.com/urfave/cli/issues/591

huangapple
  • 本文由 发表于 2017年1月27日 22:12:05
  • 转载请务必保留本文链接:https://go.coder-hub.com/41895950.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定