Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
demoManito committed Apr 12, 2023
1 parent 0d855d2 commit 050dbc4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion rules/style.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ func emptyError(m dsl.Matcher) {
//doc:tags style
func emptySlice(m dsl.Matcher) {
m.Match(`var $name = make([]$type, 0)`, `$name := []$type{}`, `$name := make([]$type, 0, 0)`, `$name := make([]$type, 0)`).
Report(`nil slice is the preferred style`).
Report(`zero-length slice declaring nil slice is better`).
Suggest(`var $name []$type`)
}
4 changes: 2 additions & 2 deletions rules/testdata/style.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func emptyError() {
}

func emptySlice() {
x := []int{} // want `\Qnil slice is the preferred style, should be: var x []int`
a := make([]int, 0, 0) // want `\Qnil slice is the preferred style, should be: var a []int`
x := []int{} // want `\QemptySlice: zero-length slice declaring nil slice is better
a := make([]int, 0, 0) // want `\QemptySlice: zero-length slice declaring nil slice is better
fmt.Println(x, a)
}

0 comments on commit 050dbc4

Please sign in to comment.