context_1_6.go 812 B

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