Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
yshngg opened this issue Apr 12, 2025 · 0 comments
Closed

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

yshngg opened this issue Apr 12, 2025 · 0 comments
Labels
Proposal ToolProposal Issues describing a requested change to a Go tool or command-line program.
Milestone

Comments

@yshngg
Copy link

yshngg commented Apr 12, 2025

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
@gopherbot gopherbot added this to the Proposal milestone Apr 12, 2025
@gabyhelp gabyhelp added the ToolProposal Issues describing a requested change to a Go tool or command-line program. label Apr 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Proposal ToolProposal Issues describing a requested change to a Go tool or command-line program.
Projects
None yet
Development

No branches or pull requests

4 participants