Consider the following Go program:
package main
func a(fn func()) {
fn()
}
func main() {
var b int
a(func() {
b = 12
})
}
(run above program on Go Playground)
b
is declared on line 8 and a value is assigned on line 10. However, vet
reports the following:
vet.exe: test.go:8:2: b declared but not used
Why does this cause a warning if it is indeed used?