global command
This commit is contained in:
36
pkg/sys/config.go
Normal file
36
pkg/sys/config.go
Normal file
@ -0,0 +1,36 @@
|
||||
package sys
|
||||
|
||||
import (
|
||||
"log"
|
||||
"sync"
|
||||
|
||||
"novit.nc/direktil/pkg/config"
|
||||
)
|
||||
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user