Skip to content

proposal: cmd/go: add -tags flag to go tool command #73347

@yshngg

Description

@yshngg

Proposal Details

Background

When using Go 1.24's tool dependency tracking with go get -tool to install the golang-migrate/migrate CLI, executing via go tool github.com/golang-migrate/migrate/v4/cmd/migrate resulted in a connection error. The root cause was a build constraint mismatch due to missing build tag specifications during invocation.

The migrate CLI requires explicit build tags (e.g., postgres, mysql) to conditionally compile database drivers. This works correctly when using go install with tags:

go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest

But go tool [tool name] command lacks explicit support for build tags (-tags) when invoked directly.

Expectation

Extend the go tool command to accept a -tags flag, propagating build tags to the underlying compilation process.

For example:

go tool -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate

Metadata

Metadata

Assignees

No one assigned

    Labels

    ProposalToolProposalIssues describing a requested change to a Go tool or command-line program.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions