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

Ignore field options (omitempty,omitzero) during Decode #90

Closed
wants to merge 2 commits into from
Closed

Ignore field options (omitempty,omitzero) during Decode #90

wants to merge 2 commits into from

Conversation

chowey
Copy link

@chowey chowey commented Aug 3, 2015

This fixes #89. Currently the only options are omitempty and omitzero, which have no significance while decoding, so these can simply be ignored.

I thought it best to use the same getOptions function so this stays unified in the future (if some additional options are added later).

@buaazp
Copy link

buaazp commented Aug 11, 2015

Yes, I meet this bug and @chowey 's PR fixed it.

If some fields has ,omitempty option, they will be ignored when decoding.

For example, in the _example/_example.go, if I modified codes to:

type ownerInfo struct {
    Name string
    Org  string `toml:"organization,omitempty"`
    Bio  string
    DOB  time.Time
}

And then run it:

./_examples
Title: TOML Example
Owner: Tom Preston-Werner (, GitHub Cofounder & CEO

You can see the Org is blank now.

@BurntSushi plz merge these codes into master branch.

@chowey
Copy link
Author

chowey commented Aug 17, 2015

Just noticed this is related to #82. I did the check in a different place.

@titanous
Copy link

This could use a test to ensure that there isn't a regression.

titanous added a commit to flynn/flynn that referenced this pull request Sep 1, 2015
From BurntSushi/toml#90

Signed-off-by: Jonathan Rudenberg <jonathan@titanous.com>
benbjohnson pushed a commit to benbjohnson/flynn that referenced this pull request Sep 4, 2015
From BurntSushi/toml#90

Signed-off-by: Jonathan Rudenberg <jonathan@titanous.com>
@chowey
Copy link
Author

chowey commented Sep 4, 2015

I added a test.

@ayufan
Copy link

ayufan commented Feb 7, 2016

@BurntSushi Could you merge this?

@cespare
Copy link
Collaborator

cespare commented Feb 23, 2016

I went with #82 instead.

@cespare cespare closed this Feb 23, 2016
ebrady pushed a commit to dvln/toml that referenced this pull request Oct 24, 2016
@chowey chowey deleted the fix-omitempty branch January 8, 2020 05:27
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

Successfully merging this pull request may close these issues.

omitempty breaks Decode
5 participants