Skip to content

Commit

Permalink
add function literal go
Browse files Browse the repository at this point in the history
  • Loading branch information
adithyvisnu committed Jun 11, 2019
1 parent ce8b8d3 commit d43658d
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions 5. GoRoutine/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,21 @@ func main() {
// for {
// go checkLink(<-c, c)
// }
// alternatives
// // alternatives
// for l := range c {
// go checkLink(l, c)
// }

for l := range c {
go checkLink(l, c)
go func() {
time.Sleep(5 * time.Second)
checkLink(l, c)
}()
}

}

func checkLink(link string, c chan string) {
time.Sleep(5 * time.Second)
_, err := http.Get(link)
if err != nil {
fmt.Println(link, "might be down!------")
Expand Down

0 comments on commit d43658d

Please sign in to comment.