Skip to content

Instantly share code, notes, and snippets.

@haeven-kelley
Created December 29, 2023 02:21
Show Gist options
  • Save haeven-kelley/0a059d6f172a59d22ce9916a235b689e to your computer and use it in GitHub Desktop.
Save haeven-kelley/0a059d6f172a59d22ce9916a235b689e to your computer and use it in GitHub Desktop.
Go routines e.g.
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