Do not write trailing dot in ini sections
Fixes #94
diff --git a/ini_private.go b/ini_private.go
index 1a671f5..fb9c4ce 100644
--- a/ini_private.go
+++ b/ini_private.go
@@ -62,9 +62,15 @@
var sname string
if len(namespace) != 0 {
- sname = namespace + "." + group.ShortDescription
- } else {
- sname = group.ShortDescription
+ sname = namespace
+ }
+
+ if len(group.ShortDescription) != 0 {
+ if len(sname) != 0 {
+ sname += "."
+ }
+
+ sname += group.ShortDescription
}
sectionwritten := false
diff --git a/ini_test.go b/ini_test.go
index 6b8553b..de2212d 100644
--- a/ini_test.go
+++ b/ini_test.go
@@ -307,6 +307,7 @@
[add.Other Options]
other = subgroup
+
`
b := strings.NewReader(inic)
@@ -323,6 +324,13 @@
}
assertString(t, opts.Add.Other.O, "subgroup")
+
+ // Test writing it back
+ buf := &bytes.Buffer{}
+
+ inip.Write(buf, IniDefault)
+
+ assertDiff(t, buf.String(), inic, "ini contents")
}
func TestIniNoIni(t *testing.T) {