Skip to content

Instantly share code, notes, and snippets.

@rockey5520
Created October 4, 2022 15:19
Show Gist options
  • Save rockey5520/fc80077e981d635df864a7ff9396d1e5 to your computer and use it in GitHub Desktop.
Save rockey5520/fc80077e981d635df864a7ff9396d1e5 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"io"
"log"
"net/http"
)
func main() {
resp, err := http.Get("https://httpbin.org/get")
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println("Response status:", resp.Status)
body, err := io.ReadAll(resp.Body)
if err != nil {
log.Fatal(err)
}
log.Println(string(body))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment