Skip to content

Instantly share code, notes, and snippets.

@sivsivsree
Created June 30, 2022 10:16
Show Gist options
  • Save sivsivsree/3e0f7b4b583526e2114939c16805c187 to your computer and use it in GitHub Desktop.
Save sivsivsree/3e0f7b4b583526e2114939c16805c187 to your computer and use it in GitHub Desktop.
// An emptyCtx is never canceled, has no values, and has no deadline. It is not
// struct{}, since vars of this type must have distinct addresses.
type emptyCtx int
func (*emptyCtx) Deadline() (deadline time.Time, ok bool) {
return
}
func (*emptyCtx) Done() <-chan struct{} {
return nil
}
func (*emptyCtx) Err() error {
return nil
}
func (*emptyCtx) Value(key any) any {
return nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment