From 22f118f3b604734b4782f0dd767171687ffd7774 Mon Sep 17 00:00:00 2001 From: Manu Mtz-Almeida Date: Sat, 13 Jun 2015 00:01:02 +0200 Subject: [PATCH] Adds gin.Bind() usage panic! --- utils.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/utils.go b/utils.go index 81c716f..7e64687 100644 --- a/utils.go +++ b/utils.go @@ -16,7 +16,14 @@ import ( const BindKey = "_gin-gonic/gin/bindkey" func Bind(val interface{}) HandlerFunc { - typ := reflect.ValueOf(val).Type() + value := reflect.ValueOf(val) + if value.Kind() == reflect.Ptr { + panic(`Bind struct can not be a pointer. Example: + Use: gin.Bind(Struct{}) instead of gin.Bind(&Struct{}) +`) + } + typ := value.Type() + return func(c *Context) { obj := reflect.New(typ).Interface() if c.Bind(obj) == nil {