What does the `…` mean in go get

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

What does the `...` mean in go get

问题

在这种情况下,...表示通配符,用于匹配指定路径下的所有子包。执行go get github.com/constabulary/gb/...命令将会下载并安装github.com/constabulary/gb包及其所有子包。

英文:

I wanted to install gb

The installation steps says to execute the command:

go get github.com/constabulary/gb/...

What does the ... mean in this case?

答案1

得分: 37

...(省略号)告诉go get命令还要获取包的子包/依赖项。

根据go help packages的说明:

如果导入路径包含一个或多个“...”通配符,则它是一个模式,每个通配符可以匹配任何字符串,包括空字符串和包含斜杠的字符串。这样的模式会扩展为在GOPATH树中找到的与模式匹配的所有包目录。作为一个特例,x/...也会匹配x及其子目录。例如,net/...会扩展为net以及其子目录中的包。

关于如何使用它的示例,请参考这个答案

英文:

The ... (ellipsis) tells go get to also fetch the package's subpackages/dependencies.

From go help packages:

> An import path is a pattern if it includes one or more "..."
> wildcards, each of which can match any string, including the empty
> string and strings containing slashes. Such a pattern expands to all
> package directories found in the GOPATH trees with names matching the
> patterns. As a special case, x/... matches x as well as x's
> subdirectories. For example, net/... expands to net and packages in
> its subdirectories.

For an example of how you'd use it, check out this answer.

huangapple
  • 本文由 发表于 2015年8月11日 17:41:00
  • 转载请务必保留本文链接:https://go.coder-hub.com/31938346.html
匿名

发表评论

匿名网友

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

确定