I noticed some surprising behavior last night. However, I'm not sure if this is actually a bug, or by design. Basically, it seems that variables can shadow types. This is very odd because Go typically has no trouble distinguishing between types and other tokens, so I don't know why a variable name should be allowed to shadow a type name.
type aStruct struct {
field int
}
func main() {
aStruct := aStruct{1} // this works
aStruct = aStruct{2} // this doesn't
fmt.Println(aStruct)
}
prog.go:11: aStruct is not a type
Was this intentional, or should I file a bug?
-Kevin
--
Kevin Ballard