Created
February 13, 2021 14:10
-
-
Save samirkape/e0c6bc9de42e35c795dee805422a7d31 to your computer and use it in GitHub Desktop.
This file contains hidden or 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() { | |
args := os.Args[1:] | |
for _, url := range args { | |
response, err := http.Get(url) | |
check_err(err, "http GET error") | |
response_body, err := ioutil.ReadAll(response.Body) | |
response.Body.Close() | |
check_err(err, "reading error") | |
fmt.Printf("%s ", response_body) | |
} | |
} | |
func check_err(err error, estr string) { | |
if err != nil { | |
fmt.Fprintf(os.Stderr, "Fetch: %s %s ", estr, err) | |
os.Exit(-2) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment