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

net/http

http package to work with http protocol

http.Client{}

creates new HTTP client object

.Get(

sends GET request to the given URL

.Body

object to access response body

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

output response body to stdout