.gitignore added
[dotfiles/.git] / .config / coc / extensions / coc-go-data / tools / pkg / mod / golang.org / x / tools@v0.1.1-0.20210319172145-bda8f5cee399 / refactor / eg / testdata / A1.go
1 package A1
2
3 import (
4         . "fmt"
5         myfmt "fmt"
6         "os"
7         "strings"
8 )
9
10 func example(n int) {
11         x := "foo" + strings.Repeat("\t", n)
12         // Match, despite named import.
13         myfmt.Errorf("%s", x)
14
15         // Match, despite dot import.
16         Errorf("%s", x)
17
18         // Match: multiple matches in same function are possible.
19         myfmt.Errorf("%s", x)
20
21         // No match: wildcarded operand has the wrong type.
22         myfmt.Errorf("%s", 3)
23
24         // No match: function operand doesn't match.
25         myfmt.Printf("%s", x)
26
27         // No match again, dot import.
28         Printf("%s", x)
29
30         // Match.
31         myfmt.Fprint(os.Stderr, myfmt.Errorf("%s", x+"foo"))
32
33         // No match: though this literally matches the template,
34         // fmt doesn't resolve to a package here.
35         var fmt struct{ Errorf func(string, string) }
36         fmt.Errorf("%s", x)
37
38         // Recursive matching:
39
40         // Match: both matches are well-typed, so both succeed.
41         myfmt.Errorf("%s", myfmt.Errorf("%s", x+"foo").Error())
42
43         // Outer match succeeds, inner doesn't: 3 has wrong type.
44         myfmt.Errorf("%s", myfmt.Errorf("%s", 3).Error())
45
46         // Inner match succeeds, outer doesn't: the inner replacement
47         // has the wrong type (error not string).
48         myfmt.Errorf("%s", myfmt.Errorf("%s", x+"foo"))
49 }