gf/geg/os/gcfg/gcfg_auto_update.go
2019-04-03 00:03:46 +08:00

21 lines
407 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"
"github.com/gogf/gf/g"
"github.com/gogf/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 {}
}