mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-17 22:32:26 +08:00
initialize the validate Settings no need to use sync.once
This commit is contained in:
parent
e5311338d1
commit
06f332fadf
@ -8,13 +8,11 @@ import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/go-playground/validator/v10"
|
||||
)
|
||||
|
||||
type defaultValidator struct {
|
||||
once sync.Once
|
||||
validate *validator.Validate
|
||||
}
|
||||
|
||||
@ -77,9 +75,10 @@ func (v *defaultValidator) Engine() interface{} {
|
||||
return v.validate
|
||||
}
|
||||
|
||||
// lazyInit initialize the validate Settings, no need to use sync.once
|
||||
func (v *defaultValidator) lazyInit() {
|
||||
v.once.Do(func() {
|
||||
if v.validate == nil {
|
||||
v.validate = validator.New()
|
||||
v.validate.SetTagName("binding")
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user