The code below: package component
import "os" type BaseicConfig struct{ } func init() { configDir := os.Getenv(constant.ProjectRootEnv) if configDir == "" { // run here. log.Panic(constant.InvalidEnvVariables) } configPath := filepath.Join(configDir, constant.ConfigName) if _, err := toml.DecodeFile(configPath, &BaseConfig); err != nil { log.Panic(err.Error()) } } I want to test it. Problem: when importing *component*, Golang will call *init() *automatically. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.