Skip to content

x/tools/go/packages: incorrect intermediate test variant computed for broken 'main' import #66126

Open
@findleyr

Description

@findleyr

In #66109, we see gopls running into a latent go/packages bug.

Consider the following setup (taken from the gopls regression test for that issue):

-- go.mod --
module example.com/tools

go 1.22

-- tools_test.go --
//go:build tools

package tools

import (
	_ "example.com/tools/tool"
)

-- tool/tool.go --
package main

func main() {
}

In this case, gopackages -test -json -deps ./tools_test.go will report a package "command-line-arguments [command-line-arguments.test]" with the nonsensical dependency ID "example.com/tools/tool [command-line-arguments.test]". This only occurs if the dep is a main package itself. It looks like go/packages thinks it has to break a cycle to the non-existent command-line-arguments package.

CC @adonovan @matloob

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsFixThe path to resolution is known, but the work has not been done.ToolsThis label describes issues relating to any tools in the x/tools repository.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions