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

Default true on bool does not allow to set false #15

Closed
Nordes opened this issue Feb 4, 2020 · 1 comment
Closed

Default true on bool does not allow to set false #15

Nordes opened this issue Feb 4, 2020 · 1 comment

Comments

@Nordes
Copy link

Nordes commented Feb 4, 2020

I explain myself since the title might looks a bit rubbish. Basically I have a yaml file (not official one)

foo:
   bar: false # You can play of changing this to true / false

I have my configuration in go:

type Foo struct {
  Bar bool `default:"true" yaml:"bar"`
}

when I do run my defaults I have something like this:

	if err := defaults.Set(myConfig); err != nil {
		panic(err)
	}
       fmt.Printf("Show me the value: %v", myConfig.Bar)
       // The result it always show: Show me the value: true

I don't have any issue with any other default except the boolean type.

Note: I didn't try to run the code currently here, but it represents pretty much what it looks like in my code. I have my code in a not so public repo.

@Nordes
Copy link
Author

Nordes commented Feb 4, 2020

My bad, it's because it's default to false (bool) then it automatically always switch to true.

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

1 participant