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

IsSet always returns true if the key is bound to a flag. #580

Closed
deinspanjer opened this issue Oct 15, 2018 · 1 comment · Fixed by #331
Closed

IsSet always returns true if the key is bound to a flag. #580

deinspanjer opened this issue Oct 15, 2018 · 1 comment · Fixed by #331
Milestone

Comments

@deinspanjer
Copy link

It is not possible to use spf13/pflag without specifying a default value, and it is not a pointer, so you cannot set it to nil. pflag does have a method Changed() which can test whether something was set with the flag, as well as unexported functions to test if the value is currently the zero value.

However, if you use viper.BindPFlag, when you call IsSet, the unexported find() method will return the value of the pflag as the very last condition, and it does not check whether it is the zero value, so it will always return true.

@fastcat
Copy link

fastcat commented Oct 18, 2019

Looks to be the same as #323, #276, attempted fixed in #331

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 a pull request may close this issue.

3 participants