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
+8.9k Golang : What is the default port number for connecting to MySQL/MariaDB database ?
+10.3k Golang : Convert file content to Hex
+6.9k Golang : Calculate BMI and risk category
+9.9k Golang : Turn string or text file into slice example
+5k Python : Convert(cast) bytes to string example
+17.6k Convert JSON to CSV in Golang
+7.9k Golang : How to feed or take banana with Gorilla Web Toolkit Session package
+16.3k Golang : Find out mime type from bytes in buffer
+6k Golang : Compound interest over time example
+9.3k Golang : How to get garbage collection data?
+5.8k Javascript : How to replace HTML inside <div>?
+4.1k Javascript : Empty an array example