Difference between `go build .` and `go build ...`?

macOS 10.14.6
go 1.15.5

Can anyone tell me (I have searched and not found anything) between building a package using go build . and using go build ...?

I have found that the first approach seems to work silently, whereas the second approach invokes a lot of visible Modules/Dependency activity and crashes sooner or later.

I’m trying this on the http://github.com/Seklfreak/discord-image-downloader-go package.

Single dot (.) means current directory only while triple dots (...) means current directory and all sub-directories recursively.

For build command, you would want to organize your executable (those main.go) in its own package and stick to single dot (.).

For unit testing, triple dots (...) makes sense as you want to test all the packages (including sub-packages) in your project.


That sounds like a reasonable explanation, except that, in this case, the workspace has no sub-directories. Certainly, the dependencies seem as if they are being downloaded recursively…
This is the package I’m working with http://github.com/Seklfreak/discord-image-downloader-go.

Have you tried ./... ?

The slash is very important. This means build current directory but with all the files in it (alongside with recursive explanations).

You need this because themain.go is coded alongside its dependent source codes in the same root directory.


The command should be something like:

$ go build -o ./path/to/my/bin/myProgram ./...
1 Like

Thanks for the reply. I must have been misremembering the ./… syntax! I’ve just tried it and it works :grinning:

1 Like

Welcome. Can you mark the appropriate post as solutions please? For forum housekeeping and archiving purposes. :upside_down_face:


This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.