golangci-lint/test/ruleguard/preferWriteString.go
Anton Telyshev c65868c105
gocritic: support of enable-all and disable-all options (#4335)
Co-authored-by: Ludovic Fernandez <ldez@users.noreply.github.com>
2024-02-19 14:50:25 +01:00

13 lines
311 B
Go

//go:build ruleguard
package ruleguard
import "github.com/quasilyte/go-ruleguard/dsl"
func preferWriteString(m dsl.Matcher) {
m.Match(`$w.Write([]byte($s))`).
Where(m["w"].Type.Implements("io.StringWriter")).
Suggest("$w.WriteString($s)").
Report(`$w.WriteString($s) should be preferred to the $$`)
}