代码拉取完成,页面将自动刷新
package util
import (
"dubbo.apache.org/dubbo-go/v3/common/logger"
"fmt"
"gitee.com/changeden/dubbo-go-starter/common"
"os"
"strings"
)
func GetEnvAndTrim(key string) string {
return strings.TrimSpace(os.Getenv(key))
}
func PresetEnv() {
common.ConfigPath = GetEnvAndTrim(common.ApplicationConfigFilePathKey) // 通过环境变量获取应用配置文件
common.DubboConfigPath = GetEnvAndTrim(common.DubboConfigFilePathKey) // Dubbo服务配置文件
if common.ConfigPath == "" {
common.ConfigPath = common.DefaultApplicationConfigFilePath // 默认配置文件
}
if common.DubboConfigPath == "" { // 默认配置文件
err := os.Setenv(common.DubboConfigFilePathKey, common.DefaultApplicationConfigFilePath)
if err != nil {
logger.Error(err)
} else {
common.DubboConfigPath = common.DefaultApplicationConfigFilePath
}
}
}
func CheckFile(path string, pathKey string) (file *os.File, err error) {
file, err = os.Open(path)
if err != nil {
logger.Error(err)
err = fmt.Errorf("环境变量[%s]所配置的文件地址[%s]不存在", pathKey, path)
}
return
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。