Skip to content

Instantly share code, notes, and snippets.

@Haeven
Created December 29, 2023 02:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Haeven/0a059d6f172a59d22ce9916a235b689e to your computer and use it in GitHub Desktop.
Save Haeven/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