package conf import ( "errors" "fmt" "git.shuncheng.lu/bigthing/gocommon/pkg/internal/constant" ) func SetAndAssertNil(config map[string]string, parent, str string, defaultValue ...string) error { if value := GetString(parent, str, defaultValue...); value != "" { config[str] = value return nil } return errors.New(fmt.Sprintf("config %s.%s is empty string or not found", parent, str)) } const ( EnvDebug = "debug" EnvTest = "test" EnvRelease = "release" ) func GetEnv() string { return GetString(constant.ApplicationName, constant.EnvName) } func GetProjectName() string { return GetString(constant.ApplicationName, constant.ProjectName) } func GetAppPort() uint64 { return GetUint64(constant.ApplicationName, constant.PortName) }