You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
go run is often used in //go:generate commands. 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)
This is a proposal to extend the syntax of the command line of
go runto allow to pass environment variables to the program that is executed after its compilation.The current syntax:
The proposed syntax:
That extended syntax will be incompatible with
=being used in the package (package name,.gofile) specification. However the language reference already mentions that a compiler implementation may exclude=from import paths.Why?
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)