func ParseConfig(v *viper.Viper) (*Config, error) {
	var c Config
	err := v.Unmarshal(&c)
	if err != nil {
		return nil, err
	}
	return &c, nil
}
ParseConfig Parse config file
package conf
import (
	"errors"
	"log"
	"strings"
	"github.com/fsnotify/fsnotify"
	"github.com/spf13/viper"
)
var (
	Conf = &Config{}
)
func Init(configPath string) (*Config, error) {
	cfgFile, err := LoadConfig(configPath)
	if err != nil {
		log.Fatalf("LoadConfig: %v", err)
	}
	Conf, err = ParseConfig(cfgFile)
	if err != nil {
		log.Fatalf("ParseConfig: %v", err)
	}
	watchConfig(cfgFile)
	return Conf, nil
}
func LoadConfig(confPath string) (*viper.Viper, error) {
	v := viper.New()
	if confPath != "" {
		v.SetConfigFile(confPath)  
	} else {
		v.AddConfigPath("config")  
		v.SetConfigName("config")
	}
	v.SetConfigType("yaml")  
	replacer := strings.NewReplacer(".", "_")
	viper.SetEnvKeyReplacer(replacer)
	if err := v.ReadInConfig(); err != nil {
		if _, ok := err.(viper.ConfigFileNotFoundError); ok {
			return nil, errors.New("config file not found")
		}
		return nil, err
	}
	return v, nil
}