Files
Sipro-Marketplaces/cmd/test/main.go

27 lines
360 B
Go

package main
import (
"context"
"sync"
"time"
)
func main() {
ctx, cacnel := context.WithTimeout(context.Background(), time.Second*5)
defer cacnel()
wg := sync.WaitGroup{}
go func() {
defer func() {
wg.Done()
println("goroutine exit")
}()
select {
case <-ctx.Done():
println("context done")
return
}
}()
wg.Add(1)
wg.Wait()
}