18 lines
285 B
Go
18 lines
285 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"strings"
|
||
|
|
||
|
"github.com/spf13/viper"
|
||
|
)
|
||
|
|
||
|
func ReadConfig() (*viper.Viper, error) {
|
||
|
v := viper.New()
|
||
|
v.SetConfigName("config")
|
||
|
v.AddConfigPath(".")
|
||
|
v.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
|
||
|
v.AutomaticEnv()
|
||
|
err := v.ReadInConfig()
|
||
|
return v, err
|
||
|
}
|