Is there a good way to reuse the code to read different configurations?
btw: I used config lib is configor
the code maybe like,
type Config1 struct {
//some config items
}
type Config2 struct {
//some config items
}
func LoadConfig1() Config1 {
var c Config1
configor.Load(&c, "MY/CONFIG1/PATH")
return c
}
func LoadConfig1() Config2 {
var c Config2
configor.Load(&c, "MY/CONFIG2/PATH")
return c
}
- Can I reuse LoadConfig with Config1/Config2?
- Can I design an object like
singleton
to create Config1/Config2 just once.