Created
October 25, 2018 01:43
-
-
Save haridutt12/9752746aa19163c49a63d1bbd2b2f56b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"io/ioutil" | |
"net/http" | |
"os" | |
) | |
func main() { | |
home := os.Args[1] | |
resp, err := http.Get("https://www.google.com/") | |
if err != nil { | |
fmt.Println("error fatching url", err) | |
os.Exit(1) | |
} | |
defer resp.Body.Close() | |
body, err := ioutil.ReadAll(resp.Body) | |
if err != nil { | |
fmt.Println(err) | |
os.Exit(1) | |
} | |
buf := make([]byte, 100000) | |
ioutil.WriteFile(home, body, 0644) | |
destData, err := os.Open(home) | |
if err != nil { | |
fmt.Println(err) | |
os.Exit(1) | |
} | |
_, _ = destData.Read(buf) | |
// a := string(body) | |
fmt.Printf("%s", buf) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment