From the HTML form you need to get the data, from this construction:

<select class="dropdown-toggle user_role" name="user_role" form="idForm" method="post"> {{range $type := .cook.TypeCook }} <option>{{$type}}</option> {{end}} </select> 

In the Go code, I don’t understand how to get the data:

 r.POST("/main/:type/", func(c *gin.Context) { var st string if c.Bind(st) == nil{ println(st) } }) 

    1 answer 1

    In HTML, you need to specify in value value, by which parameter you will choose.

    For example:

     <form action="/main/type-example/" method="POST"> <select name="user_role"> {{range $type := .cook.TypeCook }} <option value="{{$type}}">{{$type}}</option> {{end}} </select> </form> 

    And in Go you take from the form:

     r.POST("/main/:type/", func(c *gin.Context){ t := c.PostForm("user_role") })