You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
611 B
Go
26 lines
611 B
Go
1 year ago
|
package nenv
|
||
|
|
||
|
import (
|
||
|
"git.noahlan.cn/noahlan/ntool/internal/common"
|
||
|
)
|
||
|
|
||
|
// Environ like os.Environ, but will returns key-value map[string]string data.
|
||
|
func Environ() map[string]string {
|
||
|
return common.Environ()
|
||
|
}
|
||
|
|
||
|
// ParseEnvVar parse ENV var value from input string, support default value.
|
||
|
//
|
||
|
// Format:
|
||
|
//
|
||
|
// ${var_name} Only var name
|
||
|
// ${var_name | default} With default value
|
||
|
//
|
||
|
// Usage:
|
||
|
//
|
||
|
// comfunc.ParseEnvVar("${ APP_NAME }")
|
||
|
// comfunc.ParseEnvVar("${ APP_ENV | dev }")
|
||
|
func ParseEnvVar(val string, getFn func(string) string) (newVal string) {
|
||
|
return common.ParseEnvVar(val, getFn)
|
||
|
}
|