summaryrefslogtreecommitdiff
path: root/libgo/go/context/withtimeout_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/context/withtimeout_test.go')
-rw-r--r--libgo/go/context/withtimeout_test.go35
1 files changed, 0 insertions, 35 deletions
diff --git a/libgo/go/context/withtimeout_test.go b/libgo/go/context/withtimeout_test.go
deleted file mode 100644
index c74600b47b4..00000000000
--- a/libgo/go/context/withtimeout_test.go
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright 2014 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// +build ignore
-
-package context_test
-
-import (
- "context"
- "fmt"
- "time"
-)
-
-func ExampleWithTimeout() {
- // Pass a context with a timeout to tell a blocking function that it
- // should abandon its work after the timeout elapses.
- ctx, cancel := context.WithTimeout(context.Background(), 50*time.Millisecond)
-
- select {
- case <-time.After(1 * time.Second):
- fmt.Println("overslept")
- case <-ctx.Done():
- fmt.Println(ctx.Err()) // prints "context deadline exceeded"
- }
-
- // Even though ctx should have expired already, it is good
- // practice to call its cancelation function in any case.
- // Failure to do so may keep the context and its parent alive
- // longer than necessary.
- cancel()
-
- // Output:
- // context deadline exceeded
-}