pelletier/go-toml — pull request #11 by pelletier (2013-12-09 16:32:56+00:00)
Title: Comments in a multiline array cause parse error

An array of the form:

[1, # wow
2, # such items
3, # so array
]

panics with a parse error, "unterminated array" This should parse according to https://github.com/mojombo/toml#array.

The following unit test demonstrates the issue:

```
diff --git a/parser_test.go b/parser_test.go
index 7f7888e..629e0a6 100644
--- a/parser_test.go
+++ b/parser_test.go
@@ -170,6 +170,20 @@ func TestNewlinesInArrays(t *testing.T) {
})
}

+func TestArrayWithExtraComma(t *testing.T) {
+ tree, err := Load("a = [1,\n2,\n3,\n]")
+ assertTree(t, tree, err, map[string]interface{}{
+ "a": []int64{int64(1), int64(2), int64(3)},
+ })
+}
+
+func TestArrayWithExtraCommaComment(t *testing.T) {
+ tree, err := Load("a = [1, # wow\n2, # such items\n3, # so array\n]")
+ assertTree(t, tree, err, map[string]interface{}{
+ "a": []int64{int64(1), int64(2), int64(3)},
+ })
+}
+
func TestMissingFile(t *testing.T) {
_, err := LoadFile("foo.toml")
if err.Error() != "open foo.toml: no such file or directory" {

```