如何在Go lang中获得ajax post请求值?

如何在Go lang中获得ajax post请求值?,go,Go,我在Go工作。下面的代码处理客户端请求 package main import ( "net/http" "fmt" ) func main() { http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "<html><head><script>function createGroup(){var xmlhttp,n

我在
Go
工作。下面的代码处理客户端请求

package main

import (
    "net/http"
    "fmt"
 )

func main() {
  http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
    fmt.Fprintf(w, "<html><head><script>function createGroup(){var xmlhttp,number = document.getElementById('phoneNumber').value,email = document.getElementById('emailId').value; var values = {}; values.number = phoneNumber; values.email= emailId; if (window.XMLHttpRequest){xmlhttp=new XMLHttpRequest();}else{xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');}xmlhttp.open('POST','createGroup',true);xmlhttp.send(values.toString());}</script></head><body><h1>Group</h1><input type='text' name='phoneNumber' id='phoneNumber'/><input type='email' id='emailId' name='emailId'/><button onClick='createGroup()'>Create Group</button></body></html>")
 })
 http.HandleFunc("/createGroup",func(w http.ResponseWriter, r *http.Request) {
    fmt.Println(r)
    //Try to get the user information
 })
 panic(http.ListenAndServe(":8080", nil))
}
任何帮助都将不胜感激。

使用和,例如:

http.HandleFunc("/createGroup",func(w http.ResponseWriter, r *http.Request) {
    r.ParseForm()
    fmt.Println(r.Form)
    fmt.Println(r.FormValue("email"))
})

+1感谢它能工作,
注意:
在前端我使用表单提交而不是ajax。您能在示例中格式化html吗?
http.HandleFunc("/createGroup",func(w http.ResponseWriter, r *http.Request) {
    r.ParseForm()
    fmt.Println(r.Form)
    fmt.Println(r.FormValue("email"))
})