This is a creation in Article, where the information may have evolved or changed.
Go as a relative Java update language, the HTTP module itself has the implementation of the client request, following the implementation of the previous chapter Java, here to record the implementation of Go, followed by the implementation of Python
Note (GO version 1.6)
Package Mainimport ("Encoding/json" "FMT" "Io/ioutil" "net/http" "Strings")Func main () {URL:="https://xxx"Prama:="data=123456""Tokenres: =gettokenreq (URL, Prama) fmt. Println (tokenres)}func gettokenreq (URLstring, Paramastring) map[string]string{client:= &http. client{} req, err:= http. Newrequest ("POST", URL, strings. Newreader (Parama)) req. Header.add ("Content-type","application/x-www-form-urlencoded") RESP, err:=client. Do (req)ifErr! =Nil {fmt. PRINTLN (ERR)} Defer resp. Body.close () body, err:=Ioutil. ReadAll (resp. Body)ifErr! =Nil {fmt. PRINTLN (Err)} JSONSTR:=string(body) fmt. Println ("Jsonstr", Jsonstr)varDAT map[string]string ifERR: = json. Unmarshal ([]byte(JSONSTR), &dat); Err = =Nil {fmt. Println ("token", dat["token"]) } Else{fmt. Println ("json str to struct error") } returndat}