Standard library / runtime

runtime.Gosched()

Yields execution so other goroutines may run; it does not guarantee a particular scheduling order. Use synchronization for ordering. Expected stdout: 'done\n'.

Formal Syntax & Structure

go syntaxgo
func Gosched()

Working Example

Example Snippetgo
package main
import (  "fmt"  "runtime")
func main() {  done := make(chan struct{})  go func() { runtime.Gosched(); close(done) }()  <-done  fmt.Println("done")}
Go Reference