From 330f02496a648b75d51614b40c8ecff24fd932ca Mon Sep 17 00:00:00 2001 From: pelaohxc Date: Wed, 15 Jul 2020 16:21:16 -0400 Subject: [PATCH] Added timeout to HTTP requests --- main.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 0a58a36..37292fb 100644 --- a/main.go +++ b/main.go @@ -43,7 +43,11 @@ func main() { } func fetchURL(url string) ([]byte, error) { - resp, err := http.Get(url) + client := http.Client{ + Timeout: 5 * time.Second, + } + + resp, err := client.Get(url) if err != nil{ return nil, err }