陈圆
陈圆
due to [email protected] import gopkg.in/go-playground/validator.v9 so I solved this problem like this: [custom-validation/server.go](https://github.com/gin-gonic/examples/blob/3a0d22aa344fcf014612f43f5bf21f9c9997fd67/custom-validation/server.go#L9) ``` //"github.com/go-playground/validator/v10" "gopkg.in/go-playground/validator.v9" ... CheckIn time.Time `form:"check_in" binding:"required,bookabledate" time_format:"2006-01-02"` ``` it works.
结论还是有点区别,substring不是最快的。go 1.19 ```shell goos: windows goarch: amd64 pkg: percent cpu: Intel Xeon Processor (Skylake, IBRS) BenchmarkPercentageRounds/original-8 185058242 6.480 ns/op BenchmarkPercentageRounds/originalOpt-8 1000000000 0.2910 ns/op BenchmarkPercentageRounds/switch-8 1000000000 0.8603 ns/op BenchmarkPercentageRounds/tree-8 1000000000 0.2852...