9951 explained code solutions for 126 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

net/http

http package to work with http protocol

url.Values

prepares data to post

http.PostForm

post given form data to the specified URL

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

output response body to stdout