Skip to content

cmd/go: documentation of go build -o flag is misleading #36784

Closed
@perillo

Description

@perillo

The documentation of go build says:

The -o flag forces build to write the resulting executable or object
to the named output file or directory, instead of the default behavior described
in the last two paragraphs. If the named output is a directory that exists,
then any resulting executables will be written to that directory.

However an object is generated only if the -o flag specifies a file.

To make things more confusing, when I have a non main package in the project root and a main package in a sub-directory, go build -o file ./... reports:

go build: cannot write multiple packages to non-directory file

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocumentationIssues describing a change to documentation.FrozenDueToAgeGoCommandcmd/goWaitingForInfoIssue is not actionable because of missing required information, which needs to be provided.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions