dgryski / semgrep-go

Go rules for semgrep and go-ruleguard
MIT License
460 stars 37 forks source link

io.StringWriter rules #51

Closed CAFxX closed 2 years ago

CAFxX commented 2 years ago

https://gophers.slack.com/archives/C0VP8EF3R/p1660009225875149?thread_ts=1659978423.750169&cid=C0VP8EF3R

quasilyte commented 2 years ago

Note that there is also a HasMethod predicate, that is a little bit more than Implements. Implements may not do what you want due to the pointer/value receivers. HasMethod checks whether you could write x.Method() instead of checking that x implements an interface that has such a method.

For example, see: https://github.com/quasilyte/go-perfguard/blob/c6dfda39b09493689d4c6abaee32b534739603c1/perfguard/_rules/universal_rules.go#L606

CAFxX commented 2 years ago

Thanks, fixed