Skip to content
This repository has been archived by the owner on Jun 15, 2023. It is now read-only.

Commit

Permalink
use filepath.Ext to detemine config type
Browse files Browse the repository at this point in the history
  • Loading branch information
boypt committed Aug 17, 2021
1 parent 06cf167 commit 25ccab7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion engine/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,12 @@ func (c *Config) SyncViper(nc Config) {

func (c *Config) WriteDefault() error {
cf := viper.ConfigFileUsed()
if strings.HasSuffix(cf, ".yml") || strings.HasSuffix(cf, ".yaml") {
cfext := strings.ToLower(filepath.Ext(cf))
if cfext == "yml" || cfext == "yaml" {
// keeps keys cases
return c.WriteYaml(cf)
}
// viper's write make all keys lowercased
return viper.WriteConfig()
}

Expand Down

0 comments on commit 25ccab7

Please sign in to comment.