-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Open
Labels
Milestone
Description
This is a proposal to extend the syntax of the command line of go run to allow to pass environment variables to the program that is executed after its compilation.
The current syntax:
go run [build flags] [-exec xprog] package [arguments...]
The proposed syntax:
go run [build flags] [-exec xprog] [name=value ...] package [arguments...]
That extended syntax will be incompatible with = being used in the package (package name, .go file) specification. However the language reference already mentions that a compiler implementation may exclude = from import paths.
Why?
- It is useful to be able to pass to the compiled program some environment variables with values different from the values passed to
go runwhich might be needed for building the program (example: x/text/cmd/gotext: generate for one GOOS/GOARCH from a different GOOS/GOARCH #37846) go runis often used in//go:generatecommands. It is often needed to pass environment variables to the program, but there is no built-in portable way for calling a command with environment variables (env(1)is available on Unixes, but not on Windows. Workaround: github.com/dolmen-go/env)
mejediseankhliao, rittneje, jfesler, tmthrgd, aimuz and 2 more
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Incoming