2948 explained code solutions for 75 technologies

golangHTTP client example

package main

import ("net/http"; "os"; "io")

func main() {
  h := http.Client{}
  r, _ := h.Get("https://echoof.me/")
  defer r.Body.Close()
  io.Copy(os.Stdout, r.Body)
}ctrl + c
package main

default package declaration


http package to work with http protocol


creates new HTTP client object


sends GET request to the given URL


object to access response body

io.Copy(os.Stdout, r.Body)

output response body to stdout