我喜欢b站-1010(3)
// 启动时间
LaunchTime time.Time
Uptime time.Duration
Env string
Host string
Port string
BaseURL string
// CDN 资源域名
CDNHttp string
CDNHttps string
Domain string
locker sync.Mutex
}
var app = &app{}
var showVersion = flag.Bool("version", false, "Print version of this binary")
const (
DEV = "dev"
TEST = "test"
PRO = "pro"
)
func init() {
app.Name = os.Args[0]
app.Version = "V4.0.0"
app.Build = Build
app.LaunchTime = time.Now()
fileInfo, err := os.Stat(os.Args[0])
if err != nil {
panic(err)
}
app.Date = fileInfo.ModTime()
app.Env = config.ConfigFile.MustValue("global", "env")
app.CDNHttp = config.ConfigFile.MustValue("qiniu", "http_domain", DefaultCDNHttp)