summaryrefslogtreecommitdiff
path: root/vendor/github.com/gin-gonic/gin/binding
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2021-09-10 14:42:14 +0200
committerLibravatar GitHub <noreply@github.com>2021-09-10 14:42:14 +0200
commitf2e5bedea6fb93fbbf68ed8f7153c353cc57a9f0 (patch)
tree475ae9e7470d0df670ab2a59dce351cd1d07498a /vendor/github.com/gin-gonic/gin/binding
parentfixes + db changes (#204) (diff)
downloadgotosocial-f2e5bedea6fb93fbbf68ed8f7153c353cc57a9f0.tar.xz
migrate go version to 1.17 (#203)
* migrate go version to 1.17 * update contributing
Diffstat (limited to 'vendor/github.com/gin-gonic/gin/binding')
-rw-r--r--vendor/github.com/gin-gonic/gin/binding/form_mapping.go9
-rw-r--r--vendor/github.com/gin-gonic/gin/binding/protobuf.go9
-rw-r--r--vendor/github.com/gin-gonic/gin/binding/uri.go2
3 files changed, 12 insertions, 8 deletions
diff --git a/vendor/github.com/gin-gonic/gin/binding/form_mapping.go b/vendor/github.com/gin-gonic/gin/binding/form_mapping.go
index cb66dd4a7..f8b4b1239 100644
--- a/vendor/github.com/gin-gonic/gin/binding/form_mapping.go
+++ b/vendor/github.com/gin-gonic/gin/binding/form_mapping.go
@@ -26,7 +26,7 @@ var (
ErrConvertToMapString = errors.New("can not convert to map of strings")
)
-func mapUri(ptr interface{}, m map[string][]string) error {
+func mapURI(ptr interface{}, m map[string][]string) error {
return mapFormByTag(ptr, m, "uri")
}
@@ -83,7 +83,7 @@ func mapping(value reflect.Value, field reflect.StructField, setter setter, tag
return false, nil
}
- var vKind = value.Kind()
+ vKind := value.Kind()
if vKind == reflect.Ptr {
var isNew bool
@@ -210,7 +210,7 @@ func setWithProperType(val string, value reflect.Value, field reflect.StructFiel
case reflect.Int64:
switch value.Interface().(type) {
case time.Duration:
- return setTimeDuration(val, value, field)
+ return setTimeDuration(val, value)
}
return setIntField(val, 64, value)
case reflect.Uint:
@@ -310,7 +310,6 @@ func setTimeField(val string, structField reflect.StructField, value reflect.Val
t := time.Unix(tv/int64(d), tv%int64(d))
value.Set(reflect.ValueOf(t))
return nil
-
}
if val == "" {
@@ -360,7 +359,7 @@ func setSlice(vals []string, value reflect.Value, field reflect.StructField) err
return nil
}
-func setTimeDuration(val string, value reflect.Value, field reflect.StructField) error {
+func setTimeDuration(val string, value reflect.Value) error {
d, err := time.ParseDuration(val)
if err != nil {
return err
diff --git a/vendor/github.com/gin-gonic/gin/binding/protobuf.go b/vendor/github.com/gin-gonic/gin/binding/protobuf.go
index f9ece928d..a4e471535 100644
--- a/vendor/github.com/gin-gonic/gin/binding/protobuf.go
+++ b/vendor/github.com/gin-gonic/gin/binding/protobuf.go
@@ -5,10 +5,11 @@
package binding
import (
+ "errors"
"io/ioutil"
"net/http"
- "github.com/golang/protobuf/proto"
+ "google.golang.org/protobuf/proto"
)
type protobufBinding struct{}
@@ -26,7 +27,11 @@ func (b protobufBinding) Bind(req *http.Request, obj interface{}) error {
}
func (protobufBinding) BindBody(body []byte, obj interface{}) error {
- if err := proto.Unmarshal(body, obj.(proto.Message)); err != nil {
+ msg, ok := obj.(proto.Message)
+ if !ok {
+ return errors.New("obj is not ProtoMessage")
+ }
+ if err := proto.Unmarshal(body, msg); err != nil {
return err
}
// Here it's same to return validate(obj), but util now we can't add
diff --git a/vendor/github.com/gin-gonic/gin/binding/uri.go b/vendor/github.com/gin-gonic/gin/binding/uri.go
index f91ec3819..a3c0df515 100644
--- a/vendor/github.com/gin-gonic/gin/binding/uri.go
+++ b/vendor/github.com/gin-gonic/gin/binding/uri.go
@@ -11,7 +11,7 @@ func (uriBinding) Name() string {
}
func (uriBinding) BindUri(m map[string][]string, obj interface{}) error {
- if err := mapUri(obj, m); err != nil {
+ if err := mapURI(obj, m); err != nil {
return err
}
return validate(obj)