1 Star 0 Fork 0

武杰/arpc

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
config.go 929 Bytes
一键复制 编辑 原始数据 按行查看 历史
武杰 提交于 2025-03-26 07:49 +08:00 . add CommonConf
package arpc
import (
"os"
"github.com/zeromicro/go-zero/core/conf"
"github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/core/stores/redis"
"github.com/zeromicro/go-zero/rest"
)
type (
RestConf = rest.RestConf
LogConf = logx.LogConf
RedisConf = redis.RedisConf
)
type CommonConf struct {
ClusterId string `json:",default=test-cluster"`
InstanceId string `json:",default=test-instance"`
AuthKey string `json:",optional"`
}
func FillDefault(v any) error {
return conf.FillDefault(v)
}
func MustLoad(path string, v any) {
conf.MustLoad(path, v)
}
func (c *CommonConf) ReplaceEnv() {
// ClusterId
clusterId := os.Getenv("ClusterId")
if clusterId != "" {
c.ClusterId = clusterId
}
// InstanceId
instanceId := os.Getenv("InstanceId")
if instanceId != "" {
c.InstanceId = instanceId
}
// AuthKey
authkey := os.Getenv("AuthKey")
if authkey != "" {
c.AuthKey = authkey
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/AlexWoo/arpc.git
git@gitee.com:AlexWoo/arpc.git
AlexWoo
arpc
arpc
v1.1.1

搜索帮助