本书未发布

8.4. map配置

未匹配的标注
package main

/*
默认使用ConfigMap,配置使用map[string]interface{}存储。

如果访问help对象,返回的数据map["help"],不会像ConfigEudore一样层层选择对象去访问数据。

*/

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

func main() {
    app := eudore.NewApp()
    app.Set("int", 20)
    app.Set("string", "app set string")
    app.Set("bool", true)
    app.Set("struct", struct {
        Name string
        Age  int
    }{"eudore", 2020})
    app.Debugf("%#v", app.GetInt("int"))
    app.Debugf("%#v", app.GetInt("string"))
    app.Debugf("%#v", app.GetString("string"))
    app.Debugf("%#v", app.GetBool("bool"))
    app.Debugf("%#v", app.Get("struct"))
    app.Debugf("%#v", app.Get("ptr"))
    app.Debugf("%#v", app.Get(""))

    app.Set("", map[string]interface{}{
        "nil data": nil,
    })
    app.Debugf("%#v", app.Get(""))

    app.CancelFunc()
    app.Run()
}

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

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

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


暂无话题~