Skip to content

Commit

Permalink
Write default header only if DEFAULT section exists (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
kartikgupta-db authored Sep 6, 2022
1 parent 30a7de6 commit f070c24
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions cmd/configure/configure.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,11 @@ var configureCmd = &cobra.Command{
}

var buffer bytes.Buffer
//The ini library does not write [DEFAULT] header, so we always
//add the [DEFAULT] header explicitly. The section might be empty.
buffer.WriteString("[DEFAULT]\n")
if ini_cfg.Section("DEFAULT").Body() != "" {
//This configuration makes the ini library write the DEFAULT header explicitly.
//DEFAULT section might be empty
ini.DefaultHeader = true
}
_, err = ini_cfg.WriteTo(&buffer)
if err != nil {
return fmt.Errorf("write config to buffer: %w", err)
Expand Down

0 comments on commit f070c24

Please sign in to comment.