英文:
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 <code>./</code> tells to start from the current folder, <code>...</code> 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>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论