Golang的”internal error: duplicate loads” – 如何解决这个错误?

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

Golang's "internal error: duplicate loads" - how to resolve this error?

问题

我是你的中文翻译助手,以下是翻译好的内容:

我是Go语言的新手。在我的项目中,我使用了外部包。我尝试使用以下命令获取所有导入的包:

go get -v all

但是会出现重复加载错误。这个问题是什么原因造成的?我该如何解决这个错误?

go get -v all
内部错误:重复加载 unsafe
内部错误:重复加载 runtime
内部错误:重复加载 errors
内部错误:重复加载 sync/atomic
内部错误:重复加载 sync
内部错误:重复加载 io
内部错误:重复加载 unicode
内部错误:重复加载 unicode/utf8
内部错误:重复加载 bytes
内部错误:重复加载 bufio
内部错误:重复加载 math
内部错误:重复加载 strconv
内部错误:重复加载 reflect
内部错误:重复加载 encoding/binary
内部错误:重复加载 syscall
内部错误:重复加载 time
内部错误:重复加载 os
内部错误:重复加载 fmt
内部错误:重复加载 sort
内部错误:重复加载 strings
内部错误:重复加载 path/filepath
内部错误:重复加载 path
英文:

I am new in go. I have used external package in my project. I have tried to the below command for getting all imported packages,

go get -v all

It will throw duplicate loads error. What is the problem of this. How can I resolve this error ?

go get -v all
internal error: duplicate loads of unsafe
internal error: duplicate loads of runtime
internal error: duplicate loads of errors
internal error: duplicate loads of sync/atomic
internal error: duplicate loads of sync
internal error: duplicate loads of io
internal error: duplicate loads of unicode
internal error: duplicate loads of unicode/utf8
internal error: duplicate loads of bytes
internal error: duplicate loads of bufio
internal error: duplicate loads of math
internal error: duplicate loads of strconv
internal error: duplicate loads of reflect
internal error: duplicate loads of encoding/binary
internal error: duplicate loads of syscall
internal error: duplicate loads of time
internal error: duplicate loads of os
internal error: duplicate loads of fmt
internal error: duplicate loads of sort
internal error: duplicate loads of strings
internal error: duplicate loads of path/filepath
internal error: duplicate loads of path

答案1

得分: 2

不要将all作为go get的参数使用,这不是它的工作方式。

"all"是特殊的,表示"整个标准库",你不需要(也不能)使用go get获取标准库(因为它是Go安装的一部分)。

仔细阅读go工具的文档,例如通过go helpgo help get。要获取外部包foo/bar/baz,请使用go get foo/bar/baz

没有(简单、适合新手的)方法可以获取所有导入的外部包。最明智的方法是先go get外部包,然后在代码中使用它,而不是反过来。

英文:

Do not use all as argument to go get. That's not how it works.

"all" ist special and means "the whole standard library" and you don't need (and cannot) go get the standard library (as it is part of your Go installation).

Take a close look at the documentation of the go tool, e.g. by go help or go help get. To get an external package foo/bar/baz use go get foo/bar/baz.

There is no (simple, newbie suitable) way to get all imported external packages. The most sensible way is to go get the/external/package and then use it in your code, not the other way around.

huangapple
  • 本文由 发表于 2015年10月22日 14:04:53
  • 转载请务必保留本文链接:https://go.coder-hub.com/33274360.html
匿名

发表评论

匿名网友

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

确定