]> Cypherpunks.ru repositories - gostls13.git/commitdiff
errors: fix package example
authorAndrew Gerrand <adg@golang.org>
Fri, 31 May 2019 10:33:01 +0000 (20:33 +1000)
committerAndrew Gerrand <adg@golang.org>
Mon, 3 Jun 2019 22:09:05 +0000 (22:09 +0000)
The example in example_test.go requires that the whole file be
displayed; the addition of ExampleAs meant that only the body of the
package example function was shown, rather than the surrounding context.

This change moves ExampleAs to the file wrap_test.go file, restoring the
package example to its former glory.

Update #31716

Change-Id: Id0ea77bc06023b239a63c1d6a7c8b3c1dae91ce9
Reviewed-on: https://go-review.googlesource.com/c/go/+/179737
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
Reviewed-by: Jean de Klerk <deklerk@google.com>
Run-TryBot: Benny Siegert <bsiegert@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/errors/example_test.go
src/errors/wrap_test.go

index d7dd782bef3caea691ff7466acacc329f8ef2c10..5dc8841237e8c9ab615cdc28542ea80b477ca795 100644 (file)
@@ -5,9 +5,7 @@
 package errors_test
 
 import (
-       "errors"
        "fmt"
-       "os"
        "time"
 )
 
@@ -34,17 +32,3 @@ func Example() {
        }
        // Output: 1989-03-15 22:30:00 +0000 UTC: the file system has gone away
 }
-
-func ExampleAs() {
-       if _, err := os.Open("non-existing"); err != nil {
-               var pathError *os.PathError
-               if errors.As(err, &pathError) {
-                       fmt.Println("Failed at path:", pathError.Path)
-               } else {
-                       fmt.Println(err)
-               }
-       }
-
-       // Output:
-       // Failed at path: non-existing
-}
index 2055316756e427f752202b28985ef6c058026dfc..d3494145276aff37ffc73df0a3e7c709f8a4a7cc 100644 (file)
@@ -218,3 +218,17 @@ func (errorUncomparable) Is(target error) bool {
        _, ok := target.(errorUncomparable)
        return ok
 }
+
+func ExampleAs() {
+       if _, err := os.Open("non-existing"); err != nil {
+               var pathError *os.PathError
+               if errors.As(err, &pathError) {
+                       fmt.Println("Failed at path:", pathError.Path)
+               } else {
+                       fmt.Println(err)
+               }
+       }
+
+       // Output:
+       // Failed at path: non-existing
+}