What exactly can be supplied as "packages" on the go build command line?

63 views
Skip to first unread message

David Karr

unread,
Feb 10, 2022, 11:59:54 AM2/10/22
to golang-nuts
When I enter "go help build", the first few lines shows this:

  usage: go build [-o output] [build flags] [packages]

  Build compiles the packages named by the import paths,

The instructions say very little about what can be supplied as "packages". It says it can be a list of .go files, and apparently assumes all of the supplied files are in a single package , which seems like an odd assumption.

However, I discovered one resource, and from my testing, that just supplying "." (period) there also builds the application.

From what I can see, it appears that the basic help information doesn't tell the entire story about what can be supplied there, and exactly how those values are used.

What are all the legal variations of what can be supplied there, and what are the exact semantics of those values?

Ian Lance Taylor

unread,
Feb 10, 2022, 12:31:57 PM2/10/22
to David Karr, golang-nuts
See "go help packages" (on the web at
https://pkg.go.dev/cmd/go#hdr-Package_lists_and_patterns).

Ian

Kurtis Rader

unread,
Feb 10, 2022, 12:34:16 PM2/10/22
to David Karr, golang-nuts
See `go help packages` and https://go.dev/ref/spec#Packages.

On Thu, Feb 10, 2022 at 9:01 AM David Karr <davidmic...@gmail.com> wrote:
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/a6e92bac-e8d6-4cea-b451-a7a1c14af6c3n%40googlegroups.com.


--
Kurtis Rader
Caretaker of the exceptional canines Junior and Hank
Reply all
Reply to author
Forward
0 new messages