Created
December 29, 2023 02:21
-
-
Save haeven-kelley/0a059d6f172a59d22ce9916a235b689e to your computer and use it in GitHub Desktop.
Go routines e.g.
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 f(from string) { | |
for i := 0; i < 3; i++ { | |
fmt.Println(from, ":", i) | |
} | |
} | |
func main() { | |
f("direct") | |
go f("goroutine") | |
go func(msg string) { | |
fmt.Println(msg) | |
}("going") | |
time.Sleep(time.Second) | |
fmt.Println("done") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment