Process command line arguments in go test
Environmental configs are best kept in environment variables, in my experience. You can rely on global variables like so: var envSetting = os.Getenv(“TEST_ENV”) Alternatively, if using flags is a requirement, you could place your initialization code inside a function called init(). func init() { flags.Parse() myEnv = *envFlag // … }