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 required field if struct already has a default value #345

Open
kotyara85 opened this issue Dec 16, 2022 · 1 comment
Open

Ignore required field if struct already has a default value #345

kotyara85 opened this issue Dec 16, 2022 · 1 comment

Comments

@kotyara85
Copy link

Hello,
Does kong support autoignore errors if struct field has required flag and already has a value?

type Config struct {
  AppName        string `kong:"required"`
}

func main() {
cfg := Config{}
cfg.AppName = "test"

kong.Parse(&cfg) will result into error -app-name flag is not set
}

Thanks

@alecthomas
Copy link
Owner

No, Kong initialises the structure to zeroes/defaults.

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