I'm having some troubles trying to execute a POST
using Golang
. With the code below
func Postfunc(w http.ResponseWriter , rep *http.Request) {
var jsonStr = []byte(`{"id":"10012"}`)
req, err := http.NewRequest("POST", "url", bytes.NewBuffer(jsonStr))
req.Header.Set("Content-Type", "application/Text")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
fmt.Println("responce Status:", resp.Status)
fmt.Println("responce Headers:", resp.Header)
defer resp.Body.Close()
bodyText, err := ioutil.ReadAll(resp.Body)
fmt.Println("responce Body:", string(bodyText))
p := string(bodyText)
return p
}
I get the following error:
too many arguments to return, have (string), want ()
What does this error mean? How can I fix this?