Golang net/http.Client.Get() function example
package net/http
Golang net/http.Client.Get() function usage example
package main
import (
"fmt"
"io/ioutil"
"net/http"
"os"
)
func main() {
client := &http.Client{}
resp, err := client.Get("https://golang.org")
if err != nil {
fmt.Println(err)
os.Exit(1)
}
defer resp.Body.Close()
htmlData, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
fmt.Println(os.Stdout, string(htmlData))
}
See also : https://www.socketloop.com/tutorials/golang-http-get-example
Reference :
Advertisement
Something interesting
Tutorials
+27.5k Golang : dial tcp: too many colons in address
+7.7k Golang : Command line ticker to show work in progress
+7.4k Golang : Scanf function weird error in Windows
+24.5k Golang : Change file read or write permission example
+18.6k Golang : Find IP address from string
+29.2k Golang : missing Git command
+10.2k Golang : Use regular expression to get all upper case or lower case characters example
+18.2k Golang : Get command line arguments
+10.6k Android Studio : Simple input textbox and intercept key example
+7.4k Golang : How to detect if a sentence ends with a punctuation?
+22k Fix "Failed to start php5-fpm.service: Unit php5-fpm.service is masked."
+9.3k Golang : Timeout example