Tag Archives: go install

Using go test, build and install

With one exception, the go command takes arguments in the form of packages.

You can pass the package name(s) explicitly, eg.

go test github.com/hoisie/mustache

or implicitly

cd $GOPATH/src/github.com/hoisie/mustache
go test .

By default, if no arguments are provided go test treats the current directory as a package, so in the second example, go test . is identical in function to

cd $GOPATH/src/github.com/hoisie/mustache
go test

The ability to pass a single file to go {build,test,install} is a degenerate case brought about by go run accepting a single .go file as its argument.

go run should be considered the single exception to the rule outlined above.