1 Star 0 Fork 15

lankii/protocol-plugin-template

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
main.go 869 Bytes
一键复制 编辑 原始数据 按行查看 历史
hezhuozhuo 提交于 2024-07-01 14:49 +08:00 . fix bug
package main
import (
"log"
httpclient "plugin_template/http_client"
httpservice "plugin_template/http_service"
"plugin_template/mqtt"
"strings"
"github.com/spf13/viper"
)
func main() {
conf()
LogInIt()
log.Println("Starting the application...")
// 启动mqtt客户端
mqtt.InitClient()
// 启动http客户端
httpclient.Init()
// 启动服务
// go deviceconfig.Start()
// 启动http服务
httpservice.Init()
select {}
}
func conf() {
log.Println("加载配置文件...")
// 设置环境变量前缀
viper.SetEnvPrefix("plugin_template")
// 使 Viper 能够读取环境变量
viper.AutomaticEnv()
viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
viper.SetConfigType("yaml")
viper.SetConfigFile("./config.yaml")
err := viper.ReadInConfig()
if err != nil {
log.Println(err.Error())
}
log.Println("加载配置文件完成...")
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/lankii/protocol-plugin-template.git
git@gitee.com:lankii/protocol-plugin-template.git
lankii
protocol-plugin-template
protocol-plugin-template
master

搜索帮助