mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-17 22:32:26 +08:00
code style for lazyInit
This commit is contained in:
parent
34ce2104ca
commit
f8576af1f9
@ -64,7 +64,7 @@ func (v *defaultValidator) ValidateStruct(obj interface{}) error {
|
|||||||
|
|
||||||
// validateStruct receives struct type
|
// validateStruct receives struct type
|
||||||
func (v *defaultValidator) validateStruct(obj interface{}) error {
|
func (v *defaultValidator) validateStruct(obj interface{}) error {
|
||||||
v.lazyinit()
|
v.lazyInit()
|
||||||
return v.validate.Struct(obj)
|
return v.validate.Struct(obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,11 +73,11 @@ func (v *defaultValidator) validateStruct(obj interface{}) error {
|
|||||||
// or struct level validations. See validator GoDoc for more info -
|
// or struct level validations. See validator GoDoc for more info -
|
||||||
// https://pkg.go.dev/github.com/go-playground/validator/v10
|
// https://pkg.go.dev/github.com/go-playground/validator/v10
|
||||||
func (v *defaultValidator) Engine() interface{} {
|
func (v *defaultValidator) Engine() interface{} {
|
||||||
v.lazyinit()
|
v.lazyInit()
|
||||||
return v.validate
|
return v.validate
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *defaultValidator) lazyinit() {
|
func (v *defaultValidator) lazyInit() {
|
||||||
v.once.Do(func() {
|
v.once.Do(func() {
|
||||||
v.validate = validator.New()
|
v.validate = validator.New()
|
||||||
v.validate.SetTagName("binding")
|
v.validate.SetTagName("binding")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user