go接收前端传过来的方式

get请求方式:

func marixExplainPHandler(w http.ResponseWriter,rr *http.Request){
  query := rr.URL.Query()
  id :
= query.Get("id")
}

form表单传递参数

func marixExplainPHandler(w http.ResponseWriter,rr *http.Request){
  con := rr.PostFormValue("con")
  lang := rr.PostFormValue("lang")
 }

post请求正常接收参数:

func marixExplainPHandler(w http.ResponseWriter,request *http.Request){
  decoder := json.NewDecoder(request.Body)

    // 用于存放参数key=value数据
    var params map[string]string

    // 解析参数 存入map
    decoder.Decode(&params)

    fmt.Printf("POST json: username=%s, password=%s
", params["username"], params["password"])
 }
原文地址:https://www.cnblogs.com/lxz123/p/15217618.html