oc-lib/conf.go

33 lines
617 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 {
2024-07-18 13:55:38 +02:00
MongoUrl string
MongoDatabase 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{
2024-07-18 13:55:38 +02:00
MongoUrl: url,
MongoDatabase: name,
2024-07-18 13:43:41 +02:00
}
2024-07-18 11:56:54 +02:00
return instance
}