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

Should panic for invalid option values #2

Open
dolmen opened this issue Sep 1, 2023 · 3 comments
Open

Should panic for invalid option values #2

dolmen opened this issue Sep 1, 2023 · 3 comments

Comments

@dolmen
Copy link

dolmen commented Sep 1, 2023

Do not silently ignore out of range values for options. Instead, panic.

@shaovie
Copy link
Owner

shaovie commented Sep 1, 2023

yes, you are right. It has been fixed

@dolmen
Copy link
Author

dolmen commented Sep 1, 2023

Well, validation should happen earlier, out of the Option function.

func BucketsCount(v int) Option {
	if v < 1 {
		panic("BucketsCount: value out of range")
	}
	return func(o *Options) {
		o.bucketsCount = v
	}
}

@shaovie
Copy link
Owner

shaovie commented Sep 1, 2023

Sorry for being careless. You're so careful. Haha

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