package system import ( "runtime" "github.com/spf13/viper" ) type Profile struct { App string Domain string LogLevel int Prod bool Alloc uint64 TotalAlloc uint64 SysMem uint64 NumGC uint32 } func GetProfile() *Profile { var m runtime.MemStats runtime.ReadMemStats(&m) return &Profile{ App: viper.GetString("name"), Domain: viper.GetString("domain"), Prod: viper.GetBool("prod"), LogLevel: viper.GetInt("log.level"), Alloc: bToMb(m.Alloc), TotalAlloc: bToMb(m.TotalAlloc), SysMem: bToMb(m.Sys), NumGC: m.NumGC, } } func bToMb(b uint64) uint64 { return b / 1024 / 1024 }