Import ("bytes" "Encoding/json" "FMT" "Io/ioutil" "net/http") type UserInfo struct {ApiKey string ' json : "ApiKey" ' userid string ' JSON: "userid" '}type Perception struct {inputtext map[string]string ' JSON: "Inpu Ttext,omitempty "' Inputimage map[string]string ' JSON:" Inputimage,omitempty "' Selfinfo map[string]*reques Tlocation ' JSON: ' Selfinfo,omitempty ' '}type requestlocation struct {city string ' JSON: ' City,omitempty ' ' Province String ' JSON: ' Province,omitempty ' Street string ' json: ' Street,omitempty ' '}type requeststruct struct {reqtype int ' JSON: "Reqtype" ' UserInfo *userinfo ' JSON: "UserInfo" ' Perception *perception ' json: ' Perception '}ty PE Test1 struct {Id string age string Class string}type Test struct {Name string Test1 test1}func m Ain () {apiaddress: = "Http://openapi.tuling123.com/openapi/api/v2" requestruct: = &requeststruct{0, & ; Userinfo{apikey: "231ae8807c384f41805802bdd4973638 ", UserId:" 123456111 "}, &perception{inputtext:map[string]string{" text ":" What's the weather like Today "} , selfinfo:map[string]*requestlocation{"Location": &requestlocation{city: "Beijing"}}} Jsonbyte, err: = json. Marshal (requestruct) if err! = Nil {fmt. Println (Err. Error ())} else {fmt. Println (String (jsonbyte))} request, Err: = http. Newrequest ("POST", Apiaddress, Bytes. Newbuffer (jsonbyte)) if err! = Nil {fmt. Println (Err. Error ())} request. Header.set ("Content-type", "Application/json;charset=utf-8") Client: = http. client{} resp, err: = client. Do (request) if err! = Nil {fmt. Println (Err. Error ()) return} Defer resp. Body.close () respbytes, err: = Ioutil. ReadAll (resp. Body) If err! = Nil {fmt. Println (Err. Error ()) return} FMT. Println (String (respbytes))}