inits/pkg/sys/config.go

37 lines
427 B
Go
Raw Permalink Normal View History

2019-03-08 01:21:29 +00:00
package sys
import (
"log"
"sync"
2024-01-20 13:20:51 +00:00
"novit.tech/direktil/pkg/config"
2019-03-08 01:21:29 +00:00
)
const cfgPath = "/config.yaml"
var (
cfg *config.Config
cfgLock sync.Mutex
)
func Config() *config.Config {
if cfg != nil {
return cfg
}
cfgLock.Lock()
defer cfgLock.Unlock()
if cfg != nil {
return cfg
}
c, err := config.Load(cfgPath)
if err != nil {
log.Fatal("FATAL: failed to load config: ", err)
}
cfg = c
return cfg
}