github.com/EngineerKamesh/gofullstack@v0.0.0-20180609171605-d41341d7d4ee/volume1/section6/getrequest/getrequest.go (about)

     1  package main
     2  
     3  import (
     4  	"fmt"
     5  	"io/ioutil"
     6  	"log"
     7  	"net/http"
     8  )
     9  
    10  func main() {
    11  
    12  	resp, err := http.Get("http://www.google.com/")
    13  	if err != nil {
    14  		log.Fatalf("Encountered the following error: ", err)
    15  	}
    16  	defer resp.Body.Close()
    17  	body, err := ioutil.ReadAll(resp.Body)
    18  	fmt.Println(string(body))
    19  
    20  }