8000 should throw error when invalid input · Issue #96 · go-ini/ini · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

should throw error when invalid input #96

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

Closed
bruceauyeung opened this issue Apr 6, 2017 · 4 comments
Closed

should throw error when invalid input #96

bruceauyeung opened this issue Apr 6, 2017 · 4 comments

Comments

@bruceauyeung
Copy link

saying i have

[user1]
name=bruce
age=a30

my struct

type user struct {
    Name string
    Age int
}

when i try to

err = cfg.MapTo(u)

i expect an error is throwed out because a30 is not a valid int value, but actually go-ini didn't throw any error

@unknwon
Copy link
Member
unknwon commented Apr 6, 2017

Hi,

  1. This is expected behavior, currently only error that makes library impossible to continue will return an error. Other errors like type parse failure would be ignored and use zero value.
  2. I can add another method like StrictMapTo to throw error every possible error.

@bruceauyeung
Copy link
Author

@unknwon thanks for your great work! I am expecting StrictMapTo

@unknwon
Copy link
Member
unknwon commented Jun 2, 2017

Hi, StrictMapTo functions/methods have been added, please update and test!

@bruceauyeung
Copy link
Author

@unknwon tested, everything works as expected, thanks!

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
0