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

Encode without default values? #221

Closed
jcjordyn130 opened this issue May 2, 2018 · 3 comments
Closed

Encode without default values? #221

jcjordyn130 opened this issue May 2, 2018 · 3 comments

Comments

@jcjordyn130
Copy link

Would it be possible to save a toml file without the default value for unset (strings are blank, int are 0, etc) values?

@jcjordyn130
Copy link
Author

jcjordyn130 commented May 2, 2018

As of now I have
Title = "title"
Album = "album"
Artist = "artist"
AlbumArtist = ""
Composer = ""
Genre = ""
Year = 0
Track = 2
Disc = 0
AlbumArt = ""

And I want (with the values that aren't there being set to default in the struct on decode)

Title = "title"
Album = "album"
Artist = "artist"
Track = 2

@BurntSushi
Copy link
Owner

You do it the same way you would as with encoding/json. Use omitempty.

@jcjordyn130
Copy link
Author

Thanks, Tired me didn't do enough googling lol

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