gf/geg/os/gcfg/gcfg_auto_update.go

22 lines
447 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package main
import (
"fmt"
"gitee.com/johng/gf/g"
"gitee.com/johng/gf/g/os/gtime"
"time"
)
// 配置文件热更新示例
func main() {
c := g.Config()
// 每隔1秒打印当前配置项值用户可手动在外部修改文件内容gcfg读取到的配置项值会即时得到更新
gtime.SetInterval(time.Second, func() bool {
fmt.Println(c.Get("viewpath"))
return true
})
select {}
}