background_go1.5.go 874 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. //go:build !go1.7
  2. // +build !go1.7
  3. package context
  4. import "time"
  5. // An emptyCtx is a copy of the Go 1.7 context.emptyCtx type. This is copied to
  6. // provide a 1.6 and 1.5 safe version of context that is compatible with Go
  7. // 1.7's Context.
  8. //
  9. // An emptyCtx is never canceled, has no values, and has no deadline. It is not
  10. // struct{}, since vars of this type must have distinct addresses.
  11. type emptyCtx int
  12. func (*emptyCtx) Deadline() (deadline time.Time, ok bool) {
  13. return
  14. }
  15. func (*emptyCtx) Done() <-chan struct{} {
  16. return nil
  17. }
  18. func (*emptyCtx) Err() error {
  19. return nil
  20. }
  21. func (*emptyCtx) Value(key interface{}) interface{} {
  22. return nil
  23. }
  24. func (e *emptyCtx) String() string {
  25. switch e {
  26. case BackgroundCtx:
  27. return "aws.BackgroundContext"
  28. }
  29. return "unknown empty Context"
  30. }
  31. // BackgroundCtx is the common base context.
  32. var BackgroundCtx = new(emptyCtx)