gurkankaymak / hocon

go implementation of lightbend's HOCON configuration library https://github.com/lightbend/config
MIT License
79 stars 17 forks source link

Same-line comments returning errors #25

Closed pgalbavy-itrs closed 2 years ago

pgalbavy-itrs commented 2 years ago

I have no idea why this is happening, having read parser.go the comment should be consumed before the rest, but using:

package main

import "github.com/gurkankaymak/hocon"

func main() {
    _, err := hocon.ParseResource("test.conf")
    if err != nil {
        panic(err)
    }
}

with a test.conf of

# this is a test 
name: value

# another test
name2: value2 #this value is commented

I get

$ go version
go version go1.19.1 linux/amd64
$ ./play 
panic: missing comma! at: 5:15, values should have comma or ASCII newline ('\n') between them

goroutine 1 [running]:
main.main()
        /home/peter/play/main.go:8 +0x45

According to lightbend this should work:

* HOCON allows comments on the same line as a key or value, while properties files only recognize comment characters if they occur as the first character on the line