Created
August 20, 2016 14:05
-
-
Save klrkdekira/0e49f80c8c92eaead339044375c23c26 to your computer and use it in GitHub Desktop.
This file contains 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 main() { | |
for i := 1; i <= 100; i++ { | |
go fizzbuzz(i) | |
} | |
// no synchronization, just wait | |
time.Sleep(3 * time.Second) | |
} | |
func fizzbuzz(i int) { | |
msg := fmt.Sprintf("%d - ", i) | |
if i%3 == 0 { | |
msg += "fizz" | |
} | |
if i%5 == 0 { | |
msg += "buzz" | |
} | |
fmt.Println(msg) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment