Created
May 7, 2020 00:05
-
-
Save prachikhadke/a0179f375a8d513962b5a3ca4b20dc31 to your computer and use it in GitHub Desktop.
Calling go routines from go routines
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"time" | |
) | |
func SayHello(name string) { | |
fmt.Printf("Hello %s!\n", name) | |
} | |
func MeetPeople(names []string) { | |
for _, name := range names { | |
go SayHello(name) | |
} | |
} | |
func main() { | |
names := []string{"Adam", "Ben", "Caroline", "Derek", "Evan", "Farah", | |
"Goldie", "Harriet", "Ingrid", "Jake", "Lola", "Meena", "Ninoshkha", | |
"Oakley", "Pierre", "Quinn", "Ryder", "Steve", "Tom", "Uma", | |
"Vanessa", "Wade", "Xenon", "Yolanda", "Zoey"} | |
go MeetPeople(names) | |
time.Sleep(25 * time.Second) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment