2948 explained code solutions for 75 technologies

golangHow to make POST (form data) request using HTTP client

package main

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

func main() {
  data := url.Values{ "name": {"John Doe"} }
  r, _ := http.PostForm("https://echoof.me", data)
  defer r.Body.Close()
  io.Copy(os.Stdout, r.Body)
}ctrl + c
package main

default package declaration


http package to work with http protocol


prepares data to post


post given form data to the specified URL

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

output response body to stdout