get response data golang http code example
Example: golang get request data
package main
func fetchResponse(url string) string{
resp, _ := http.Get(url)
defer resp.Body.Close()
body, _ := ioutil.ReadAll(resp.Body)
return string(body)
}
func main() {
resp := fetchResponse("http://someurl.com")
fmt.Println(resp)
}