Skip to content

Instantly share code, notes, and snippets.

@samirkape
Created February 13, 2021 14:10
Show Gist options
  • Save samirkape/e0c6bc9de42e35c795dee805422a7d31 to your computer and use it in GitHub Desktop.
Save samirkape/e0c6bc9de42e35c795dee805422a7d31 to your computer and use it in GitHub Desktop.
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