Skip to content

Go packge info paths are incorrect according to package specs #337

@goddenrich

Description

@goddenrich

https://pkg.go.dev/golang.org/x/tools/go/packages#Package specifies

type Package struct {
	// ID is a unique identifier for a package,
	// in a syntax provided by the underlying build system.
	//
	// Because the syntax varies based on the build system,
	// clients should treat IDs as opaque and not attempt to
	// interpret them.
	ID [string](https://pkg.go.dev/builtin#string)

	// Name is the package name as it appears in the package source code.
	Name [string](https://pkg.go.dev/builtin#string)

	// PkgPath is the package path as used by the go/types package.
	PkgPath [string](https://pkg.go.dev/builtin#string)

	// Dir is the directory associated with the package, if it exists.
	//
	// For packages listed by the go command, this is the directory containing
	// the package files.
	Dir [string](https://pkg.go.dev/builtin#string)

	// Errors contains any errors encountered querying the metadata
	// of the package, or while parsing or type-checking its files.
	Errors [][Error](https://pkg.go.dev/golang.org/x/tools/go/packages#Error)

	// TypeErrors contains the subset of errors produced during type checking.
	TypeErrors [][types](https://pkg.go.dev/go/types).[Error](https://pkg.go.dev/go/types#Error)

	// GoFiles lists the absolute file paths of the package's Go source files.
	// It may include files that should not be compiled, for example because
	// they contain non-matching build tags, are documentary pseudo-files such as
	// unsafe/unsafe.go or builtin/builtin.go, or are subject to cgo preprocessing.
	GoFiles [][string](https://pkg.go.dev/builtin#string)

	// CompiledGoFiles lists the absolute file paths of the package's source
	// files that are suitable for type checking.
	// This may differ from GoFiles if files are processed before compilation.
	CompiledGoFiles [][string](https://pkg.go.dev/builtin#string)

	// OtherFiles lists the absolute file paths of the package's non-Go source files,
	// including assembly, C, C++, Fortran, Objective-C, SWIG, and so on.
	OtherFiles [][string](https://pkg.go.dev/builtin#string)

	// EmbedFiles lists the absolute file paths of the package's files
	// embedded with go:embed.
	EmbedFiles [][string](https://pkg.go.dev/builtin#string)

	// EmbedPatterns lists the absolute file patterns of the package's
	// files embedded with go:embed.
	EmbedPatterns [][string](https://pkg.go.dev/builtin#string)

	// IgnoredFiles lists source files that are not part of the package
	// using the current build configuration but that might be part of
	// the package using other build configurations.
	IgnoredFiles [][string](https://pkg.go.dev/builtin#string)

	// ExportFile is the absolute path to a file containing type
	// information for the package as provided by the build system.
	ExportFile [string](https://pkg.go.dev/builtin#string)

	// Target is the absolute install path of the .a file, for libraries,
	// and of the executable file, for binaries.
	Target [string](https://pkg.go.dev/builtin#string)

	// Imports maps import paths appearing in the package's Go source files
	// to corresponding loaded Packages.
	Imports map[[string](https://pkg.go.dev/builtin#string)]*[Package](https://pkg.go.dev/golang.org/x/tools/go/packages#Package)

	// Module is the module information for the package if it exists.
	//
	// Note: it may be missing for std and cmd; see Go issue #65816.
	[Module](https://pkg.go.dev/golang.org/x/tools/go/packages#Module) *Module
}

In particular all paths should be absolute paths not relative paths. However the paths provided are relative paths to the root of the repo. https://github.com/please-build/go-rules/blob/master/tools/please_go/packageinfo/packageinfo.go#L133.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions