Standard library / go/build
go/build.NoGoError.Error()
Returns human-readable package-discovery diagnostic text. Avoid depending on the exact message. Expected stdout: 'true\n'.
Formal Syntax & Structure
go syntaxgo
func (e *NoGoError) Error() stringReturn Value
string
Returns human-readable package-discovery diagnostic text.
Working Example
Example Snippetgo
package main
import ( "errors" "fmt" "go/build" "os" "strings")
func check(e error) { if e != nil { panic(e) }}
func main() { d, e := os.MkdirTemp("", "build-error-") check(e) defer os.RemoveAll(d) _, e = build.ImportDir(d, 0) var x *build.NoGoError ok := errors.As(e, &x) fmt.Println(ok && strings.Contains(x.Error(), d))}