shad-go/urlfetch/main.go

28 lines
374 B
Go
Raw 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 {
log.Fatal("fetch:", err)
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
log.Fatal("fetch:", err)
}
fmt.Println(string(body))
}
2020-02-13 19:54:24 +00:00
}