Files
deep_go/lessons/contexts/with_ctx_check/main.go

19 lines
255 B
Go

package main
import "context"
func WithContexCheck(ctx context.Context, action func()) {
if action == nil || ctx.Err() != nil {
return
}
action()
}
func main() {
ctx := context.Background()
WithContexCheck(ctx, func() {
// do something
})
}