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
+7.4k Golang : Count leading or ending zeros(any item of interest) example
+27.8k Golang : How to declare kilobyte, megabyte, gigabyte, terabyte and so on?
+11.1k Golang : Listen and Serve on sub domain example
+29.5k error: trying to remove "yum", which is protected
+4.5k How to check with curl if my website or the asset is gzipped ?
+10.6k Golang : convert(cast) float to string
+18.1k Golang : Delete item from slice based on index/key position
+6.1k Golang : Of hash table and hash map
+10.1k CodeIgniter : How to check if a session exist in PHP?
+12k Golang : Image to ASCII art example
+12k Golang : Read from buffered reader until specific number of bytes
+21.3k Golang : Test file read write permission example