You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
unused: false positive when only use is constant expression #812
$ staticcheck -version
staticcheck 2020.1.5
$ staticcheck -debug.version
staticcheck 2020.1.5
Compiled with Go version: go1.14.4
Main module:
honnef.co/go/tools@v0.0.1-2020.1.5 (sum: h1:nI5egYTGJakVyOryqLs1cQO5dO0ksin5XXs2pspk75k=)
Dependencies:
github.com/BurntSushi/toml@v0.3.1 (sum: h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=)
golang.org/x/tools@v0.0.0-20191130070609-6e064ea0cf2d (sum: h1:/iIZNFGxc/a7C3yWjGcnboV+Tkc7mxr+p6fDztwoxuM=)
$ go version
go version go1.15 darwin/amd64
go env provided upon request.
package main
import (
"io""unsafe"
)
var (
w io.Writersz=unsafe.Sizeof(w)
)
funcmain() {
println(sz)
}
$ go run main.go
16
$ staticcheck main.go
main.go:9:2: var w is unused (U1000)
changed the title [-]unused: false positive for zero value interface at package level[/-][+]unused: false positive when only use is constant expression[/+]on May 30, 2021
Activity
dgryski commentedon Aug 20, 2020
A workaround:
sz = unsafe.Sizeof((io.Writer)(nil))[-]unused: false positive for zero value interface at package level[/-][+]unused: false positive when only use is constant expression[/+]kortschak commentedon Jun 29, 2022
I see a similar case that I can't see a similar work around for.
unused: reimplement check using the AST