123456789101112131415161718192021222324252627 |
- package config
- import (
- "os"
- "github.com/spf13/viper"
- )
- func init() {
- viper.SetConfigName("shopperthree_manage")
- viper.SetConfigType("yaml")
- viper.AddConfigPath(".")
- viper.AddConfigPath("..")
- viper.AddConfigPath("/etc/shopperthree_manage")
- if err := viper.ReadInConfig(); err != nil {
- panic(err)
- }
- if path := viper.GetString("log.path"); path != "" {
- f, err := os.OpenFile(path, os.O_CREATE|os.O_RDWR|os.O_APPEND, os.ModePerm)
- if err != nil {
- panic(err)
- }
- os.Stdout = f
- os.Stderr = f
- }
- }
|