Skip to content

go/packages: returned packages are deduplicated #30828

Closed
@josharian

Description

@josharian

Using Go 1.12.

// +build ignore

package main

import (
	"fmt"

	"golang.org/x/tools/go/packages"
)

func main() {
	cfg := &packages.Config{
		Mode: packages.LoadImports,
	}

	initial, err := packages.Load(cfg, "fmt", "fmt")
	if err != nil {
		panic(err)
	}
	for _, x := range initial {
		fmt.Println(x.PkgPath)
	}
}

Got:

$ go run bug.go
fmt

Want:

$ go run bug.go
fmt
fmt

Related: #30826. This is important to me for the same reasons.

(For the record, neither of these bugs is theoretical. I hit both of them working on go-fuzz; this one I hit while trying to work around #30826.)

cc @matloob

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions