oc-lib/conf.go

35 lines
633 B
Go
Raw Normal View History

2024-07-16 10:56:36 +02:00
package oclib
import "sync"
// ===================================================
// This class has to be updated everytime
// a new configuration variable is defined
// in a componant that imports oc-lib
// ===================================================
type Config struct {
MongoURL string
2024-07-18 11:56:54 +02:00
DCNAME string
DBPOINT string
2024-07-16 10:56:36 +02:00
}
var instance *Config
var once sync.Once
func GetConfig() *Config {
once.Do(func() {
instance = &Config{}
})
return instance
}
2024-07-18 11:56:54 +02:00
2024-07-18 13:43:41 +02:00
func SetConfig(url string, name string, point string) *Config {
instance = &Config{
MongoURL: url,
DCNAME: name,
DBPOINT: point,
}
2024-07-18 11:56:54 +02:00
return instance
}