Last active
September 7, 2019 11:14
-
-
Save sitetester/b7184388f5ea5454197958e0c497f462 to your computer and use it in GitHub Desktop.
This will create directory (if not exists) and will write a new file to it
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
resp, _ := http.Get(GoogleUrl) | |
defer resp.Body.Close() | |
body, _ := ioutil.ReadAll(resp.Body) | |
dir := "resources" | |
if _, err := os.Stat(dir); os.IsNotExist(err) { | |
os.Mkdir("."+string(filepath.Separator)+dir, 0777) | |
} | |
newPath := filepath.Join(dir, "google.html") | |
fmt.Println(newPath) | |
ioutil.WriteFile(newPath, body, 0644) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment