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
I was writing some new Go code, and wanted to assign an unused struct to the blank identifier to prevent a compiler error.
package main
funcmain() {
_=int(5) // ok_=struct{ int }{} // ok_=struct{ int }{5} // okvar_=int(5) // okvar_=struct{ int }{} // okvar_=struct{ int }{5} // cannot use _ as value
}
What version of Go are you using (
go version
)?What operating system and processor architecture are you using (
go env
)?What did you do?
I was writing some new Go code, and wanted to assign an unused struct to the blank identifier to prevent a compiler error.
https://play.golang.org/p/KZlFqfhE1z
What did you expect to see?
No compile errors. (Probably? I'm not sure if this is intended behavior or not, but it doesn't seem to be.)
What did you see instead?
I got "cannot use _ as value" compile error.
Additional Notes
I tried
gc
compiler from Go 1.4.3, and got the same error.go/types
doesn't seem to give an error for that code.The text was updated successfully, but these errors were encountered: