Golang net/http.Post() function example
package net/http
Golang net/http.Post() function usage example
package main
import (
"fmt"
"net/http"
"net/url"
"strings"
)
func main() {
urlData := url.Values{}
urlData.Set("search_query", "pixar")
resp, err := http.Post("https://www.youtube.com/results?search_query=", "text/plain", strings.NewReader(urlData.Encode()))
if err != nil {
fmt.Println(err)
}
fmt.Println("Status : ", resp.Status)
}
References :
http://golang.org/pkg/net/http/#Post
https://www.socketloop.com/tutorials/golang-post-data-with-url-values
Advertisement
Something interesting
Tutorials
+19.6k Golang : Close channel after ticker stopped example
+9.6k Golang : How to generate Code 39 barcode?
+41.9k Golang : How do I convert int to uint8?
+6k Linux/MacOSX : Search for files by filename and extension with find command
+17.5k Golang : Clone with pointer and modify value
+10.9k Golang : Get UDP client IP address and differentiate clients by port number
+25.7k Golang : How to write CSV data to file
+25.4k Golang : Convert long hexadecimal with strconv.ParseUint example
+9.9k Golang : Turn string or text file into slice example
+5.8k Javascript : How to replace HTML inside <div>?
+12.9k Golang : Convert IPv4 address to packed 32-bit binary format
+5.7k Get website traffic ranking with Similar Web or Alexa