1 Star 0 Fork 0

linngc / central-mirror

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
embedfs_config.go 1.16 KB
一键复制 编辑 原始数据 按行查看 历史
linngc 提交于 2024-04-01 16:44 . update:提取speedsdk扩张到工具包
// Package embedfs
// @Link https://gitee.com/linngc/central-mirror
// @Copyright Copyright (c) 2024 central-mirror CLI
// @Author linngc
// @License
package embedfs
import (
"encoding/json"
"github.com/creasty/defaults"
"github.com/gogf/gf/v2/encoding/gyaml"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/util/gconv"
)
var cCfgConfig = &CfgConfig{}
type CfgConfig struct {
Storage string `yaml:"storage" default:"./storage" dc:"本地存储文件路径"`
}
// GetCfgConfig 获取配置的资源文件信息
func GetCfgConfig() *CfgConfig {
return cCfgConfig
}
// Config 初始化配置参数信息到内存
// @param str string
func Config(str string) {
//get, _ := g.Cfg().Get(todo, consts.EmbedFsStr)
// 解析yaml
if err := gyaml.DecodeTo(gconv.Bytes(str), cCfgConfig); err != nil {
g.Log().Errorf(todo, "yaml配置文件Unmarshal解析[EmbedFs 存储]出错 %v", err)
return
}
// 添加默认值
if err := defaults.Set(cCfgConfig); err != nil {
g.Log().Errorf(todo, "添加[EmbedFs 存储]默认值出错 %v", err)
return
}
//
marshal, _ := json.Marshal(cCfgConfig)
g.Log().Debugf(todo, "[EmbedFs 存储]启动参数: %s", marshal)
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/linngc/central-mirror.git
git@gitee.com:linngc/central-mirror.git
linngc
central-mirror
central-mirror
33d5664f4339

搜索帮助

344bd9b3 5694891 D2dac590 5694891