Giant blob of minor changes
[dotfiles/.git] / .config / coc / extensions / coc-go-data / tools / pkg / mod / golang.org / x / xerrors@v0.0.0-20200804184101-5ec99f83aff1 / example_As_test.go
1 // Copyright 2019 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 package xerrors_test
6
7 import (
8         "fmt"
9         "os"
10
11         "golang.org/x/xerrors"
12 )
13
14 func ExampleAs() {
15         _, err := os.Open("non-existing")
16         if err != nil {
17                 var pathError *os.PathError
18                 if xerrors.As(err, &pathError) {
19                         fmt.Println("Failed at path:", pathError.Path)
20                 }
21         }
22
23         // Output:
24         // Failed at path: non-existing
25 }