21 lines
326 B
Go
21 lines
326 B
Go
|
package setting
|
||
|
|
||
|
import "github.com/spf13/viper"
|
||
|
|
||
|
type Setting struct {
|
||
|
vp *viper.Viper
|
||
|
}
|
||
|
|
||
|
func NewSetting() (*Setting, error) {
|
||
|
vp := viper.New()
|
||
|
vp.SetConfigName("config")
|
||
|
vp.AddConfigPath("configs/")
|
||
|
vp.SetConfigType("yaml")
|
||
|
err := vp.ReadInConfig()
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
|
||
|
return &Setting{vp}, nil
|
||
|
}
|