本书未发布

8.9. 读取文件配置

未匹配的标注
package main

/*
在Config默认解析函数ConfigAllParseFunc中包含eudore.ConfigParseJSON函数,用于解析json文件。
*/

import (
    "github.com/eudore/eudore"
    "os"
)

var filepath = "example.json"

func main() {
    // 创建一个测试配置文件
    content := []byte(`{
    "default": true,
    "help": true,
    "mods.debug": {
        "debug": true
    }
}
`)
    tmpfile, _ := os.Create(filepath)
    defer os.Remove(tmpfile.Name())
    tmpfile.Write(content)

    app := eudore.NewApp()
    // 设置config路径
    app.Set("config", filepath)
    app.Set("help", true)
    app.Options(app.Parse())
    // app.CancelFunc()
    app.Run()
}

反馈和交流请加群组:QQ群373278915

本文章首发在 LearnKu.com 网站上。

上一篇 下一篇
讨论数量: 0
发起讨论 只看当前版本


暂无话题~