Skip to content

x/tools/gopls: some build errors aren't reported #43816

Open
@hyangah

Description

@hyangah

go version: go1.16beta1
gopls version: v0.6.4

how to repro

$ tree
.
├── [id].go
├── go.mod
└── lib
    └── a
        └── a.go

2 directories, 3 files

$ cat go.mod
module work

go 1.15

$ cat [id].go
package main

import "work/lib/a"

func main() {
	println(a.V)
}

$ cat lib/a/a.go
package a

var V = "Searching all the dark corners for every foot gun we can get our tentacles on..."

The go command is unhappy about the file name [id].go

$ go build
package work: invalid input file name "[id].go"

What I expected to see

gopls detects the problem and reports it as diagnostic message.

What I saw instead

gopls doesn't report any error.

Things get more confusing if we rename the lib directory to _lib directory.
Now gopls reports a compiler error, but that's not about the file name.
Screen Shot 2021-01-20 at 6 26 47 PM

Finally, if I fixed the file name - rename [id].go to id.go (but kept using _lib directory) , the error message disappear and go build also succeeds.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ToolsThis label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions