mirror of
https://github.com/YspCoder/clawgo.git
synced 2026-04-13 06:47:30 +08:00
26 lines
340 B
Go
26 lines
340 B
Go
package runtimecfg
|
|
|
|
import (
|
|
"sync/atomic"
|
|
|
|
"github.com/YspCoder/clawgo/pkg/config"
|
|
)
|
|
|
|
var current atomic.Value // *config.Config
|
|
|
|
func Set(cfg *config.Config) {
|
|
if cfg == nil {
|
|
return
|
|
}
|
|
current.Store(cfg)
|
|
}
|
|
|
|
func Get() *config.Config {
|
|
v := current.Load()
|
|
if v == nil {
|
|
return nil
|
|
}
|
|
cfg, _ := v.(*config.Config)
|
|
return cfg
|
|
}
|