35 lines
633 B
Go
35 lines
633 B
Go
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
|
|
DCNAME string
|
|
DBPOINT string
|
|
}
|
|
|
|
var instance *Config
|
|
var once sync.Once
|
|
|
|
func GetConfig() *Config {
|
|
once.Do(func() {
|
|
instance = &Config{}
|
|
})
|
|
return instance
|
|
}
|
|
|
|
func SetConfig(url string, name string, point string) *Config {
|
|
instance = &Config{
|
|
MongoURL: url,
|
|
DCNAME: name,
|
|
DBPOINT: point,
|
|
}
|
|
return instance
|
|
}
|