-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Is func (*Validate) Struct
thread-safe ?
#315
Comments
Hey @7fELF great question And the answer is yes it is completely thread/goroutine safe and is designed to be used with a single instance. Validator also caches information about your struct and validations, in essence only parsing your validation tags once per struct type, without a single instance you wouldn’t get the advantages of the cache. |
Thanks for the quick answer 😄 |
Could be this represented somewhere in the documentation? There are some functions noted as not thread-safe which is not really an assurance that the other functions are thread-safe. |
PRs welcome @andrascz |
Package version:
v9
Issue, Question or Enhancement:
Question
I'm using
func (*Validate) Struct
to validate API requests.Is that safe to use only one instance of
Validate
for the whole project considering there may be simultaneous calls to(*Validate) Struct()
?The text was updated successfully, but these errors were encountered: