-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
default_config.go
123 lines (95 loc) · 2.49 KB
/
default_config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
package main
import "fmt"
type asdf struct {
test string
}
func noParams() {
return
}
var c = func() {
return
}
var d = func() error {
return nil
}
var e = func() (err error) { // want `named return "err" with type "error" found`
err = nil
return
}
var e2 = func() (_ error) {
return
}
func deferWithError() (err error) { // want `named return "err" with type "error" found`
defer func() {
err = nil // use flag to allow this
}()
return
}
var (
f = func() {
return
}
g = func() error {
return nil
}
h = func() (err error) { // want `named return "err" with type "error" found`
err = nil
return
}
h2 = func() (_ error) {
return
}
)
// this should not match as the implementation does not need named parameters (see below)
type funcDefintion func(arg1, arg2 interface{}) (num int, err error)
func funcDefintionImpl(arg1, arg2 interface{}) (int, error) {
return 0, nil
}
func funcDefintionImpl2(arg1, arg2 interface{}) (num int, err error) { // want `named return "num" with type "int" found` `named return "err" with type "error" found`
return 0, nil
}
func funcDefintionImpl3(arg1, arg2 interface{}) (num int, _ error) { // want `named return "num" with type "int" found`
return 0, nil
}
func funcDefintionImpl4(arg1, arg2 interface{}) (_ int, _ error) {
return 0, nil
}
var funcVar = func() (msg string) { // want `named return "msg" with type "string" found`
msg = "c"
return msg
}
var funcVar2 = func() (_ string) {
msg := "c"
return msg
}
func test() {
a := funcVar()
_ = a
var function funcDefintion
function = funcDefintionImpl
i, err := function("", "")
_ = i
_ = err
function = funcDefintionImpl2
i, err = function("", "")
_ = i
_ = err
}
func good(i string) string {
return i
}
func bad(i string, a, b int) (ret1 string, ret2 interface{}, ret3, ret4 int, ret5 asdf) { // want `named return "ret1" with type "string" found` `named return "ret2" with type "interface{}" found` `named return "ret3" with type "int" found` `named return "ret4" with type "int" found` `named return "ret5" with type "asdf" found`
x := "dummy"
return fmt.Sprintf("%s", x), nil, 1, 2, asdf{}
}
func bad2() (msg string, err error) { // want `named return "msg" with type "string" found` `named return "err" with type "error" found`
msg = ""
err = nil
return
}
func myLog(format string, args ...interface{}) {
return
}
type obj struct{}
func (o *obj) func1() (err error) { return nil } // want `named return "err" with type "error" found`
func (o *obj) func2() (_ error) { return nil }