From cecc48030c00fa78e0ec95678f98b19103309d6f Mon Sep 17 00:00:00 2001 From: ryuichi1208 Date: Wed, 14 Feb 2024 23:19:05 +0900 Subject: [PATCH] add 0201 --- tmp/go.mod | 3 +++ tmp/main.go | 31 +++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 tmp/go.mod create mode 100644 tmp/main.go diff --git a/tmp/go.mod b/tmp/go.mod new file mode 100644 index 0000000..06a11c9 --- /dev/null +++ b/tmp/go.mod @@ -0,0 +1,3 @@ +module mm + +go 1.21.5 diff --git a/tmp/main.go b/tmp/main.go new file mode 100644 index 0000000..31b08f4 --- /dev/null +++ b/tmp/main.go @@ -0,0 +1,31 @@ +package main + +import ( + "fmt" + "io/ioutil" + "net/http" +) + +func main() { + client := &http.Client{} + req, err := http.NewRequest("GET", "http://example.com", nil) + if err != nil { + fmt.Println(err) + return + } + + resp, err := client.Do(req) + if err != nil { + fmt.Println(err) + return + } + defer resp.Body.Close() + + body, err := ioutil.ReadAll(resp.Body) + if err != nil { + fmt.Println(err) + return + } + + fmt.Println(string(body)) +}