What do three dots "./…" mean in Go command line invocations?

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

What do three dots "./..." mean in Go command line invocations?

问题

如果你在Travis CI上运行Golang测试,它将使用三个点下载所有依赖项

go get -d -v ./... && go build -v ./...

在这里,./...表示什么或者展开成什么?我做了一些研究,但似乎这不是Unix的惯例。

英文:

If you run Golang tests on Travis CI, it will download all of your dependencies with three dots:

go get -d -v ./... && go build -v ./...

What does ./... indicate or expand to there? I've done some research but it doesn't seem to be a Unix convention.

答案1

得分: 191

从命令go help packages中:

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

英文:

From the command 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.

答案2

得分: 89

你好!以下是翻译好的内容:

go [command] ./...
这里的<code>./</code>表示从当前文件夹开始,<code>...</code>表示递归向下。

**例如:**

go list ...
在任何文件夹中列出所有的包,包括标准库的包在前,然后是Go工作区中的外部库。


<details>
<summary>英文:</summary>

    go [command] ./...
Here &lt;code&gt;./&lt;/code&gt; tells to start from the current folder, &lt;code&gt;...&lt;/code&gt; tells to go down recursively.

**For Example:**

    go list ...
In any folder lists all the packages, including packages of the standard library first followed by external libraries in your go workspace.

</details>



huangapple
  • 本文由 发表于 2015年1月20日 02:52:15
  • 转载请务必保留本文链接:https://go.coder-hub.com/28031603.html
匿名

发表评论

匿名网友

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

确定