shad-go/urlfetch/main.go

28 lines
371 B
Go
Raw Permalink Normal View History

2022-02-10 22:06:57 +00:00
//go:build !solution
2020-02-13 19:54:24 +00:00
package main
import (
"fmt"
"io"
"log"
"net/http"
"os"
)
2020-02-13 19:54:24 +00:00
func main() {
urls := os.Args[1:]
for _, url := range urls {
resp, err := http.Get(url)
if err != nil {
2024-06-05 19:57:17 +00:00
log.Panic("fetch:", err)
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
2024-06-05 19:57:17 +00:00
log.Panic("fetch:", err)
}
2024-06-05 23:15:25 +00:00
fmt.Printf("%s", body)
}
2020-02-13 19:54:24 +00:00
}