Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Another comment oddity #26

Closed
pgalbavy-itrs opened this issue Nov 7, 2022 · 3 comments
Closed

Another comment oddity #26

pgalbavy-itrs opened this issue Nov 7, 2022 · 3 comments

Comments

@pgalbavy-itrs
Copy link

Thanks for the rapid fix of #25

I am trying to support in-the-field config files, so I have to test against messy files.

In this case:

"key": {
    "name": value
    # comment on it's own line - this is OK
    "name2": value
    # comment on it's own line - remove this and it works
    "name3": {
        "another": value
    }
}

generates:

$ ./play 
panic: invalid config object! at: 9:1, invalid token }

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

removing the second comment - when it precedes a { ... } fixes it.

@gurkankaymak
Copy link
Owner

thanks for reporting, the problem was with the ' character, if a line contains it the golang parser appends newline (\n) to the latest token instead of a separate token, in that case the next line is also consumed as comment

@pgalbavy-itrs
Copy link
Author

Again, thanks for the rapid fix, but found yet another one. I can share our full default config file if it helps?

key: {
    # //
    name: {
        name: value
    }
}

Any URL in a comment before a { ... } encodes object causes an error - I will assume it's the '//' being seen as a comment as well and getting something out of sync. I have not checked what happens for /* ... */ inside # or // prefixed single lines, but I am guessing it's going to have similar issues...

@pgalbavy-itrs
Copy link
Author

Yep, this also fails:

key: {
    # /* this is not ok */
    name: {
        name: value
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants