Code Monkey home page Code Monkey logo

go-repro-tools-cause-duplicated-depserrors's Introduction

Reproducing duplicated DepsErrors caused by executable imports

This repository contains a minimal module in which go list emits duplicated DepsErrors entries, that in turn cause gopls to error out with

internal error: go list gives conflicting information for package <name> [<name>.test]

As far as I can tell, this looks very much like golang/go#34321.

Besides the errors emitted by go list and gopls, a package like this compiles, tests and runs (if main) just fine.

A confluence of factors

For this issue to manifest, a package has to have two things:

  1. a Go file that imports executable packages (such as tools)
  2. a Go test file

One without the other does not make go list behave this way.

Seeing is believing

To observe the DepsErrors duplication, run

go list -mod=readonly -e -json -test=true -tags=tools ./foo | grep -B3 -A7 ImportStack
	],
	"DepsErrors": [
		{
			"ImportStack": [
				"github.com/antichris/go-repro-tools-cause-duplicated-depserrors/foo"
			],
			"Pos": "foo/tools.go:5:8",
			"Err": "import \"rsc.io/hello\" is a program, not an importable package"
		}
	],
	"TestGoFiles": [
--
	],
	"DepsErrors": [
		{
			"ImportStack": [
				"github.com/antichris/go-repro-tools-cause-duplicated-depserrors/foo"
			],
			"Pos": "foo/tools.go:5:8",
			"Err": "import \"rsc.io/hello\" is a program, not an importable package"
		}
	]
}
--
	],
	"DepsErrors": [
		{
			"ImportStack": [
				"github.com/antichris/go-repro-tools-cause-duplicated-depserrors/foo"
			],
			"Pos": "foo/tools.go:5:8",
			"Err": "import \"rsc.io/hello\" is a program, not an importable package"
		},
		{
			"ImportStack": [
				"github.com/antichris/go-repro-tools-cause-duplicated-depserrors/foo"
			],
			"Pos": "foo/tools.go:5:8",
			"Err": "import \"rsc.io/hello\" is a program, not an importable package"
		}
	],
	"TestGoFiles": [

The last two matches are two identical entries in the same DepsErrors block. Although they don't appear to be contradictory to the human eye, gopls errors out with a complaint about "conflicting information".

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.