Skip to content
Myr

update error(err) to err (#1416)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

the pull request update `return error(err)` to `return err`, and remove `kindOfData`.

authored by 田欧 · committed by Bo-Yi Wu · parent eb9f313 · Browse files · 2 files+10 added−14 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+10 added−14 removed

  • other:+10 added−14 removed

2 files+10 added−14 removed

modified:binding/binding.go+2 added-3 removed
2 unmodified lines
3// license that can be found in the LICENSE file.45package binding67import (8 "net/http"9)7import "net/http"89// Content-Type MIME of the most common data formats.10const (11 MIMEJSON = "application/json"12 MIMEHTML = "text/html"13 MIMEXML = "application/xml"
86 unmodified lines
modified:binding/default_validator.go+8 added-11 removed
16 unmodified lines
17}1819var _ StructValidator = &defaultValidator{}2021// ValidateStruct receives any kind of type, but only performed struct or pointer to struct type.22func (v *defaultValidator) ValidateStruct(obj interface{}) error {23 value := reflect.ValueOf(obj)24 valueType := value.Kind()25 if valueType == reflect.Ptr {26 valueType = value.Elem().Kind()27 }22 if kindOfData(obj) == reflect.Struct {28 if valueType == reflect.Struct {29 v.lazyinit()30 if err := v.validate.Struct(obj); err != nil {25 return error(err)31 return err32 }33 }34 return nil35}
12 unmodified lines
48 config := &validator.Config{TagName: "binding"}49 v.validate = validator.New(config)50 })51}4647func kindOfData(data interface{}) reflect.Kind {48 value := reflect.ValueOf(data)49 valueType := value.Kind()50 if valueType == reflect.Ptr {51 valueType = value.Elem().Kind()52 }53 return valueType54}