Answers for "golang read response body"

Go
0

golang read response body

//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)
Posted by: Guest on January-24-2021

Browse Popular Code Answers by Language