title: Creating a variable of type from interface in golang
body: <p>I am trying to create validator/binder middleware in go using gin framework.</p>
  
  <p>This is the model</p>
  
  <pre><code>type LoginForm struct{
      Email string `json:"email" form:"email" binding:"email,required"`
      Password string `json:"password" form:"password" binding:"required"`
  }
  </code></pre>
  
  <p>Router</p>
  
  <pre><code>router.POST("/login",middlewares.Validator(LoginForm{}) ,controllers.Login)
  </code></pre>
  
  <p>Middleware </p>
  
  <pre><code>func Validator(v interface{}) gin.HandlerFunc{
      return func(c *gin.Context){
          a := reflect.New(reflect.TypeOf(v))
          err:=c.Bind(&amp;a)
          if(err!=nil){
              respondWithError(401, "Login Error", c)
              return
          }
          c.Set("LoginForm",a)
          c.Next()
      }
  }
  </code></pre>
  
  <p>I am very new to golang. I understand the problem is with the binding to the wrong variable.
  Is there any other way of solving this?</p>