mirror of
https://github.com/spf13/viper
synced 2025-05-06 20:27:17 +00:00
Need to truncate the file before writing
This commit is contained in:
parent
543b9ec4c1
commit
0ea954cb0d
1 changed files with 1 additions and 1 deletions
2
viper.go
2
viper.go
|
@ -1245,7 +1245,7 @@ func (v *Viper) writeConfig(filename string, force bool) error {
|
|||
}
|
||||
var flags int
|
||||
if force == true {
|
||||
flags = os.O_CREATE | os.O_WRONLY
|
||||
flags = os.O_CREATE | os.O_TRUNC | os.O_WRONLY
|
||||
} else {
|
||||
if _, err := os.Stat(filename); os.IsNotExist(err) {
|
||||
flags = os.O_WRONLY
|
||||
|
|
Loading…
Add table
Reference in a new issue