...

Text file src/cmd/go/testdata/script/list_parse_err.txt

Documentation: cmd/go/testdata/script

     1# 'go list' without -e should fail and print errors on stderr.
     2! go list ./p
     3stderr '^p[/\\]b.go:2:2: expected ''package'', found ''EOF''$'
     4! go list -f '{{range .Imports}}{{.}} {{end}}' ./p
     5stderr '^p[/\\]b.go:2:2: expected ''package'', found ''EOF''$'
     6! go list -test ./t
     7stderr '^go: can''t load test package: t[/\\]t_test.go:8:1: expected declaration, found ʕ'
     8! go list -test -f '{{range .Imports}}{{.}} {{end}}' ./t
     9stderr '^go: can''t load test package: t[/\\]t_test.go:8:1: expected declaration, found ʕ'
    10
    11# 'go list -e' should report imports, even if some files have parse errors
    12# before the import block.
    13go list -e -f '{{range .Imports}}{{.}} {{end}}' ./p
    14stdout '^fmt '
    15
    16# 'go list' should report the position of the error if there's only one.
    17go list -e -f '{{.Error.Pos}} => {{.Error.Err}}' ./p
    18stdout 'b.go:[0-9:]+ => expected ''package'', found ''EOF'''
    19
    20# 'go test' should report the position of the error if there's only one.
    21go list -e -test -f '{{if .Error}}{{.Error.Pos}} => {{.Error.Err}}{{end}}' ./t
    22stdout 't_test.go:[0-9:]+ => expected declaration, found ʕ'
    23
    24-- go.mod --
    25module m
    26
    27go 1.13
    28
    29-- p/a.go --
    30package a
    31
    32import "fmt"
    33
    34-- p/b.go --
    35// no package statement
    36
    37-- t/t_test.go --
    38package t
    39
    40import "testing"
    41
    42func Test(t *testing.T) {}
    43
    44// scan error
    45ʕ◔ϖ◔ʔ

View as plain text