Building packages

The Go tools reduce the complexity of compiling your code by applying certain conventions and sensible defaults. Although a full discussion of Go's build tool is beyond the scope of this section (or chapter), it is useful to understand the purpose and use of the build and install tools. In general, the use of the build and install tools is as follows:

$> go build [<package import path>]

The import path can be explicitly provided or omitted altogether. The build tool accepts the import path expressed as either fully qualified or relative paths. Given a properly setup workspace, the following are all equivalent ways to compile package volt, from the earlier example:

$> cd $GOPATH/src/github.com/vladimirvivien/learning-go $> go build ...

Get Go: Design Patterns for Real-World Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.