gurkankaymak / hocon

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

Unable to use the .(dot) and whitespace in the unquoted strings #23

Closed floating-cat closed 2 years ago

floating-cat commented 2 years ago

Example config and code:

url = aaa.bbb.ccc
number = one two

https://go.dev/play/p/oO5cGGJ4RiF

Errors:

invalid value! at: 1:10, unknown value: "."

From the spec: https://github.com/lightbend/config/blob/main/HOCON.md#unquoted-strings https://github.com/lightbend/config/blob/main/HOCON.md#string-value-concatenation

Unquoted strings A sequence of characters outside of a quoted string is a string value if: it does not contain "forbidden characters": '$', '"', '{', '}', '[', ']', ':', '=', ',', '+', '#', '`', '^', '?', '!', '@', '*', '&', '' (backslash), or whitespace. it does not contain the two-character string "//" (which starts a comment) its initial characters do not parse as true, false, null, or a number.

String value concatenation ... So for example foo bar baz parses as three unquoted strings, and the three are value-concatenated into one string. The inner whitespace is kept and the leading and trailing whitespace is trimmed. The equivalent string, written in quoted form, would be "foo bar baz".

The unquoted strings are valid to contain the .. Also, the one two is valid too.

This config works in other Hocon libraries and here too: https://hocon-playground.herokuapp.com/