spf13 / viper

Go configuration with fangs
MIT License
27.32k stars 2.02k forks source link

default section in ini file deleted #1092

Open waynemetcalfe opened 3 years ago

waynemetcalfe commented 3 years ago

https://github.com/spf13/viper/blob/fb4eafdd9775508c450b90b1b72affeef4a68cf5/viper.go#L1743

Forgive me if this is the correct behaviour for an ini file but why is the [default] section name being removed? I am using viper to update the aws credentials file and upon calling WriteConfig, the default section heading is deleted?

github-actions[bot] commented 3 years ago

👋 Thanks for reporting!

A maintainer will take a look at your issue shortly. 👀

In the meantime: We are working on Viper v2 and we would love to hear your thoughts about what you like or don't like about Viper, so we can improve or fix those issues.

⏰ If you have a couple minutes, please take some time and share your thoughts: https://forms.gle/R6faU74qPRPAzchZ9

📣 If you've already given us your feedback, you can still help by spreading the news, either by sharing the above link or telling people about this on Twitter:

https://twitter.com/sagikazarmark/status/1306904078967074816

Thank you! ❤️

lyssar commented 5 months ago

This issue is still present. This viper behaviour breaks the AWS CLI. AWS needs the [default] group, if not present it is not a valid ini file and therefore awscli will stop working. Please elaborate on this issue why viper is removing the default group if present? I would expect that my ini file is the same after opening and saving it without changes.

sagikazarmark commented 5 months ago

Honestly, I'm not sure why that was added. I would have to look up some history to figure that out.

lyssar commented 5 months ago

Would be nice if your could do that. Would it make sense to add the possibility to choose if the default group should be persisted or not?

sagikazarmark commented 5 months ago

By the way, I'm thinking about dropping INI support from the core and moving it to an external package: https://github.com/go-viper/encoding