Skip to content

Commit

Permalink
Added timeout to HTTP requests
Browse files Browse the repository at this point in the history
  • Loading branch information
pelaohxc committed Jul 15, 2020
1 parent d458f61 commit 330f024
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 330f024

Please sign in to comment.