diff --git a/go.mod b/go.mod index 78da69f..b14e632 100644 --- a/go.mod +++ b/go.mod @@ -5,5 +5,5 @@ go 1.13 require ( github.com/gorilla/handlers v1.4.2 github.com/gorilla/mux v1.7.4 - github.com/verzth/go-utils v0.1.0 + github.com/verzth/go-utils v0.1.1 ) diff --git a/go.sum b/go.sum index d5e5e4a..270dbe4 100644 --- a/go.sum +++ b/go.sum @@ -10,3 +10,5 @@ github.com/verzth/go-utils v0.0.1 h1:2ntXZMxhjUyegqEglNPUctbpc5NoRfF+AgNs2Q4ULN0 github.com/verzth/go-utils v0.0.1/go.mod h1:VRAnwae+xXZT8FwlbZFKmgUB5U/DzHAfuREIxitR/FA= github.com/verzth/go-utils v0.1.0 h1:PheN6mb1kyAB/x4eSWUFUETZ6QrqTlUSQ0mueMZe2pQ= github.com/verzth/go-utils v0.1.0/go.mod h1:VRAnwae+xXZT8FwlbZFKmgUB5U/DzHAfuREIxitR/FA= +github.com/verzth/go-utils v0.1.1 h1:IZeqWr5IP/bgVYIHZXrCQe3rx9/WUJaRrDnF5vlOOtA= +github.com/verzth/go-utils v0.1.1/go.mod h1:VRAnwae+xXZT8FwlbZFKmgUB5U/DzHAfuREIxitR/FA= diff --git a/request.go b/request.go index c4ff534..635f123 100644 --- a/request.go +++ b/request.go @@ -207,7 +207,7 @@ func (r *Request) GetAll() map[string] interface{} { func (r *Request) Get(key string) string { val := reflect.ValueOf(r.params[key]) - if r.params[key] != nil || (val.Kind() == reflect.Slice && val.Len() > 0){ + if r.params[key] != nil || (val.IsValid() && val.Kind() == reflect.Slice && val.Len() > 0){ return fmt.Sprintf("%v", r.params[key]) } return "" @@ -465,9 +465,13 @@ func (r *Request) Filled(keys... string) (found bool) { for _, key := range keys { found = found && r.has(key) val := reflect.ValueOf(r.params[key]) - switch val.Kind() { - case reflect.String: found = found && strings.TrimSpace(r.Get(key)) != "" - case reflect.Slice: found = found && val.Len() > 0 + if val.IsValid() { + switch val.Kind() { + case reflect.String: found = found && strings.TrimSpace(r.Get(key)) != "" + case reflect.Slice: found = found && val.Len() > 0 + } + }else{ + found = false } } return