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

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

View as plain text