We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
The gin framework I use will cause fatal errors when there are too many concurrent accesses.
fatal error: concurrent map writes
// implements the binding.StructValidator type customValidator struct{} func (c *customValidator) ValidateStruct(ptr interface{}) error { govalidator.ParamTagMap["google"] = govalidator.ParamValidator(func(str string, params ...string) bool { a.Log.Debug("customGoogle ParamTagMap") return false }) govalidator.ParamTagMap["google"] = govalidator.ParamValidator(func(str string, params ...string) bool { a.Log.Debug("customGoogle ParamTagMap") return false }) // Add your own struct validation tags with parameter govalidator.ParamTagMap["compared"] = govalidator.ParamValidator(func(str string, params ...string) bool { res := reflect.ValueOf(ptr).Elem().FieldByName(params[0]).Interface().(string) return str == res }) //register the regex for validate govalidator.ParamTagRegexMap["compared"] = regexp.MustCompile("^compared\\((\\w+)\\)$") if _, err := govalidator.ValidateStruct(ptr); err != nil { a.Log.Errorf("ValidateStruct err:%v", err) return err } return nil } func (c *customValidator) Engine() interface{} { return nil } func main(){ binding.Validator = &customValidator{} r := gin.Default() r.Run(":9191") }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
The gin framework I use will cause fatal errors when there are too many concurrent accesses.
fatal error: concurrent map writes
The text was updated successfully, but these errors were encountered: