golang两种get请求获取携带参数的方式

1、  ?id=2&name=hello

    id := context.Query("id")
    name := context.Request.URL.Query().Get("name")
    var u model.User
   if context.Bind(&u) == nil {
        fmt.Println(u.Id)

2、  /user/2/hello

// 获取请求参数
    id := context.Param("id")
    name := context.Param("username")

正在整理笔记,如雷同,请告知,必添加!

原文地址:https://www.cnblogs.com/qzhc/p/13454617.html