Question : golang read response body
Answered by : ahmed-ali
//import package
import "io/ioutil"
//code snippet bodyBytes, err := ioutil.ReadAll(resp.Body) //---------- optioninal --------------------- //handling Errors if err != nil { log.Fatal(err) } //print result bodyString := string(bodyBytes) log.Info(bodyString)
Source : https://stackoverflow.com/questions/38673673/access-http-response-as-string-in-go | Last Update : Sun, 31 Jan 21