$ go version
go version devel +447965d4e0 Sun Jan 27 04:18:10 2019 +0000 linux/amd64
$ cat f.go
package p
import "go/types"
func _() {
var _ types.const
}
$ go build f.go
# command-line-arguments
./f.go:6:8: cannot refer to unexported name types._
./f.go:6:14: syntax error: unexpected const, expecting name
Of course, here I fat-fingered the type and meant types.Const. I encountered this in a real program, and the types._ error had me confused for a second. I presume that the first of the two errors should not be printed, as the second error contains all the information the user needs.
Interestingly enough, seems like the go/* packages don't do a particularly better job here:
f.go:6:14: expected 'IDENT', found 'const'
f.go:6:14: _ not declared by package types
The text was updated successfully, but these errors were encountered:
$ go version
go version go1.18.2 linux/amd64
$ cat f.go
package p
import "go/types"
func _() {
var _ types.const
}
$ go build f.go
# command-line-arguments
./f.go:6:21: syntax error: unexpected const, expecting name
mvdan commentedJan 31, 2019
Of course, here I fat-fingered the type and meant
types.Const
. I encountered this in a real program, and thetypes._
error had me confused for a second. I presume that the first of the two errors should not be printed, as the second error contains all the information the user needs.Interestingly enough, seems like the
go/*
packages don't do a particularly better job here:The text was updated successfully, but these errors were encountered: