ReadConfig read config
(configFilePath string)
| 97 | |
| 98 | // ReadConfig read config |
| 99 | func ReadConfig(configFilePath string) (c *AllConfig, err error) { |
| 100 | if len(configFilePath) == 0 { |
| 101 | configFilePath = filepath.Join(path.ConfigFileDir, path.DefaultConfigFileName) |
| 102 | } |
| 103 | c = &AllConfig{} |
| 104 | config, err := viper.NewWithPath(configFilePath) |
| 105 | if err != nil { |
| 106 | return nil, err |
| 107 | } |
| 108 | if err = config.Parse(&c); err != nil { |
| 109 | return nil, err |
| 110 | } |
| 111 | c.SetDefault() |
| 112 | c.SetEnvironmentOverrides() |
| 113 | return c, nil |
| 114 | } |
| 115 | |
| 116 | // RewriteConfig rewrite config file path |
| 117 | func RewriteConfig(configFilePath string, allConfig *AllConfig) error { |
no test coverage detected