Esempio n. 1
0
func New(fallbackConfigFile, fallbackEnvironment string) *Goenv {
	configFilePath := GetEnv("GO_CONFIG", fallbackConfigFile)
	configFile := yaml.ConfigFile(configFilePath)
	if configFile == nil {
		panic("goenv failed to open configFile: " + configFilePath)
	}

	environment := GetEnv("GO_ENV", fallbackEnvironment)
	return &Goenv{
		configFile:  configFile,
		environment: environment,
	}
}
Esempio n. 2
0
func NewGoenv(configFile, environment, logFile string) *Goenv {
	if environment == "" {
		environment = "development"
	}

	goenv := &Goenv{
		configFile:  yaml.ConfigFile(configFile),
		environment: environment,
	}

	if goenv.configFile == nil {
		panic("goenv failed to open configFile: " + configFile)
	}

	if logFile == "" {
		logFile = goenv.Get("log_file", "./log/server.log")
		os.MkdirAll(path.Dir(logFile), 0755)
		setLogFile(logFile)
	}

	return goenv
}