mirror of
https://github.com/bcicen/ctop.git
synced 2024-08-30 18:23:19 +00:00
35 lines
635 B
Go
35 lines
635 B
Go
package config
|
|
|
|
import (
|
|
"os"
|
|
|
|
"github.com/bcicen/ctop/logging"
|
|
)
|
|
|
|
var (
|
|
GlobalParams []*Param
|
|
GlobalSwitches []*Switch
|
|
log = logging.Init()
|
|
)
|
|
|
|
func Init() {
|
|
for _, p := range params {
|
|
GlobalParams = append(GlobalParams, p)
|
|
log.Debugf("loaded config param: \"%s\": \"%s\"", p.key, p.val)
|
|
}
|
|
|
|
for _, s := range switches {
|
|
GlobalSwitches = append(GlobalSwitches, s)
|
|
log.Debugf("loaded config switch: \"%s\": %t", s.key, s.val)
|
|
}
|
|
}
|
|
|
|
// Return env var value if set, else return defaultVal
|
|
func getEnv(key, defaultVal string) string {
|
|
val := os.Getenv(key)
|
|
if val != "" {
|
|
return val
|
|
}
|
|
return defaultVal
|
|
}
|