go-zero/example/config/loadfromyaml/main.go

22 lines
315 B
Go
Raw Normal View History

2020-07-26 17:09:05 +08:00
package main
import (
"time"
2020-08-08 16:40:10 +08:00
"github.com/tal-tech/go-zero/core/conf"
"github.com/tal-tech/go-zero/core/logx"
2020-07-26 17:09:05 +08:00
)
type TimeHolder struct {
Date time.Time `json:"date"`
}
func main() {
th := &TimeHolder{}
err := conf.LoadConfig("./date.yml", th)
if err != nil {
logx.Error(err)
}
logx.Infof("%+v", th)
}