go1.27 will introduce generic methods.
unusedmethod analyzer is not working as expected with those new elements.
main.go
package main
func main() {
var g G[string]
var _ I = g
g.m("foo")
var h H
h.m[string]("foo")
}
type G[P any] struct{}
func (G[P]) m(P) {}
type I interface {
m(string)
}
type H struct{}
func (H) m[P any](P) {}
Details
version: 2
linters:
default: none
enable:
- iface
settings:
iface:
enable:
- unusedmethod
$ ./golangci-lint run
main.go:18:2: unusedmethod: method 'm()' is declared on interface 'I' but not used within the package (iface)
m(string)
^
1 issues:
* iface: 1
go1.27 will introduce generic methods.
unusedmethodanalyzer is not working as expected with those new elements.main.go
Details