197

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.

Kevin Burke
  • 61,194
  • 76
  • 188
  • 305

2 Answers2

193

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.

Kevin Burke
  • 61,194
  • 76
  • 188
  • 305
  • 17
    So it's similar to the `**` wildcard implemented by some shells. – Keith Thompson Jan 19 '15 at 19:16
  • 4
    Conceptually similar to `**` for sure, the cool part is that it's only files relevant to `go`, and that it works the same across platforms and shells. I'm pretty new to Go, and this pleases me ^__^ – floer32 Mar 12 '20 at 00:02
89
go [command] ./...

Here ./ tells to start from the current folder, ... 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.

Emdadul Sawon
  • 5,730
  • 3
  • 45
  • 48
  • 1
    ahhh That is why `go build ...` take some time (about a minute or more... don't recall), it was compiling every package, right? – Victor Apr 11 '23 at 03:04