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

Support customize delimiters #166

Closed
forest0 opened this Issue Oct 6, 2018 · 5 comments

Comments

Projects
None yet
2 participants
@forest0
Copy link

forest0 commented Oct 6, 2018

It seems that the parser takes =: as delimiters, can you provide an option
to let users customize their delimiters?

Currently I am parsing a file whose keys contain :, say keee:y=value,
since : is viewed as a delimiter, I can not extract keee:y as the key.

@Unknwon

This comment has been minimized.

Copy link
Member

Unknwon commented Oct 10, 2018

If you can edit the file, try :

"keee:y"=value
@forest0

This comment has been minimized.

Copy link

forest0 commented Oct 12, 2018

Thanks for your reply.

The application I am writing configuration for can just understand the format like keee:y=value,
i.e., " is illegal.

At present, to get it work, I have to modify some lines of this library to let : is not viewed as a delimiter.

@Unknwon Unknwon changed the title support customize delimiters Support customize delimiters Oct 14, 2018

@Unknwon

This comment has been minimized.

Copy link
Member

Unknwon commented Oct 14, 2018

Thanks for your reply.

The application I am writing configuration for can just understand the format like keee:y=value,
i.e., " is illegal.

At present, to get it work, I have to modify some lines of this library to let : is not viewed as a delimiter.

Thanks, make sense to me, I'll come up something.

Unknwon added a commit that referenced this issue Oct 14, 2018

@Unknwon

This comment has been minimized.

Copy link
Member

Unknwon commented Oct 14, 2018

Pull the latest change, and try as follows:

ini/ini_test.go

Lines 1235 to 1243 in 9c8236e

func Test_KeyValueDelimiters(t *testing.T) {
Convey("Custom key-value delimiters", t, func() {
f, err := ini.LoadSources(ini.LoadOptions{
KeyValueDelimiters: "?!",
}, []byte(`
[section]
key1?value1
key2!value2
`))

@forest0

This comment has been minimized.

Copy link

forest0 commented Oct 15, 2018

Nice work! 👍

@Unknwon Unknwon closed this Oct 15, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment