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
Some operations mark all fields in a struct as used, because we can't do any better. One example is converting to unsafe.Pointer – who knows what the user will do with the data afterwards.
Unfortunately, we're only marking the immediate fields as used:
type t struct {
a, b int
c t2
}
type t2 struct {
d, e int
}
func Foo() {
var x t
_ = unsafe.Pointer(&x)
}
$ run-dev-staticcheck baz.go
baz.go:11:2: field d is unused (U1000)
baz.go:11:5: field e is unused (U1000)
Fields d and e should also be marked as used, as they are part of t's memory layout. The same problem occurs for embedded fields.
The text was updated successfully, but these errors were encountered:
Some operations mark all fields in a struct as used, because we can't do any better. One example is converting to
unsafe.Pointer
– who knows what the user will do with the data afterwards.Unfortunately, we're only marking the immediate fields as used:
Fields
d
ande
should also be marked as used, as they are part oft
's memory layout. The same problem occurs for embedded fields.The text was updated successfully, but these errors were encountered: