diff --git a/rules/style.go b/rules/style.go index 27d486e..8d08e40 100644 --- a/rules/style.go +++ b/rules/style.go @@ -38,9 +38,7 @@ func emptyError(m dsl.Matcher) { //doc:after var x []int //doc:tags style func emptySlice(m dsl.Matcher) { - m.Match(`var $name = make([]$type, 0)`, - `$name := []$type{}`, `$name = []$type{}`, - `$name := make([]$type, 0, 0)`, `$name := make([]$type, 0)`). + 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`). Suggest(`var $name []$type`) } diff --git a/rules/testdata/style.go b/rules/testdata/style.go index 3525a6e..e82e257 100644 --- a/rules/testdata/style.go +++ b/rules/testdata/style.go @@ -27,7 +27,7 @@ func emptyError() { } func emptySlice() { - x := []int{} // want `\Qnil slice is the preferred style, should be: var x []int` - x = []int{} // want `\Qnil slice is the preferred style, should be: var x []int` - fmt.Println(x) + 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` + fmt.Println(x, a) }