Answer the question
In order to leave comments, you need to log in
How to set the encoding on request?
This is a request to the page to get a JSON object.
package main
import (
"io/ioutil"
"log"
"net/http"
)
func main() {
MakeRequest()
}
func MakeRequest() {
resp, err := http.Get("http//example.com")
if err != nil {
log.Fatal(err)
}
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Fatal(err)
}
log.Println(string(body))
}
Answer the question
In order to leave comments, you need to log in
Perhaps you need to set the encoding?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question