1 Star 0 Fork 0

青榄 / goadmincore

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
preprocessor.go 416 Bytes
一键复制 编辑 原始数据 按行查看 历史
wangxinghong 提交于 2021-10-05 16:51 . 新建
package reader
import (
"os"
"regexp"
)
func ReplaceEnvVars(raw []byte) ([]byte, error) {
re := regexp.MustCompile(`\$\{([A-Za-z0-9_]+)\}`)
if re.Match(raw) {
dataS := string(raw)
res := re.ReplaceAllStringFunc(dataS, replaceEnvVars)
return []byte(res), nil
} else {
return raw, nil
}
}
func replaceEnvVars(element string) string {
v := element[2 : len(element)-1]
el := os.Getenv(v)
return el
}
1
https://gitee.com/qlanwl/goadmincore.git
git@gitee.com:qlanwl/goadmincore.git
qlanwl
goadmincore
goadmincore
e99d2202423a

搜索帮助

53164aa7 5694891 3bd8fe86 5694891