Skip to content

Commit 66ac4b5

Browse files
authored
ireturn: update tests & docs (#3800)
1 parent cbc3a0c commit 66ac4b5

File tree

5 files changed

+32
-2
lines changed

5 files changed

+32
-2
lines changed

.golangci.reference.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1159,13 +1159,14 @@ linters-settings:
11591159
max: 5
11601160

11611161
ireturn:
1162-
# ireturn allows using `allow` and `reject` settings at the same time.
1162+
# ireturn does not allow using `allow` and `reject` settings at the same time.
11631163
# Both settings are lists of the keywords and regular expressions matched to interface or package names.
11641164
# keywords:
11651165
# - `empty` for `interface{}`
11661166
# - `error` for errors
11671167
# - `stdlib` for standard library
11681168
# - `anon` for anonymous interfaces
1169+
# - `generic` for generic interfaces added in go 1.18
11691170

11701171
# By default, it allows using errors, empty interfaces, anonymous interfaces,
11711172
# and interfaces provided by the standard library.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
linters-settings:
2+
ireturn:
3+
reject:
4+
- generic
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//golangcitest:args -Eireturn
2+
//golangcitest:config_path testdata/configs/ireturn_reject_generics.yml
3+
package testdata
4+
5+
import (
6+
"bytes"
7+
"io"
8+
)
9+
10+
func NewWriter() io.Writer {
11+
var buf bytes.Buffer
12+
return &buf
13+
}
14+
15+
func TestError() error {
16+
return nil
17+
}
18+
19+
func Get[K comparable, V int64 | float64](m map[K]V) V { // want `Get returns generic interface \(V\)`
20+
var s V
21+
for _, v := range m {
22+
s += v
23+
}
24+
return s
25+
}

test/testdata/ireturn_reject_stdlib.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//golangcitest:args -Eireturn
2-
//golangcitest:config_path testdata/configs/ireturn_stdlib_reject.yml
2+
//golangcitest:config_path testdata/configs/ireturn_reject_stdlib.yml
33
package testdata
44

55
import (

0 commit comments

Comments
 (0)