Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/tools/go/packages: log.Fatalf inside library routine #45584

Open
rsc opened this issue Apr 15, 2021 · 3 comments
Open

x/tools/go/packages: log.Fatalf inside library routine #45584

rsc opened this issue Apr 15, 2021 · 3 comments
Assignees
Milestone

Comments

@rsc
Copy link
Contributor

@rsc rsc commented Apr 15, 2021

This program triggers a log.Fatalf inside golang.org/x/tools/go/packages.

% ls
go.mod	go.sum	x.go
% cat go.mod
module m

go 1.16

require golang.org/x/tools v0.1.0 // indirect
% cat x.go
package main

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

func main() {
	cfg := &packages.Config{
		Mode: packages.NeedName | packages.NeedTypes | packages.NeedExportsFile,
	}
	packages.Load(cfg, "fmt")
}
% go run .
2021/04/15 10:31:34 Unexpected package creation during export data loading
exit status 1
%
@rsc rsc added this to the Unreleased milestone Apr 15, 2021
@rsc rsc changed the title golang.org/x/tools/go/packages: golang.org/x/tools/go/packages: log.Fatalf inside library routine Apr 15, 2021
@rsc
Copy link
Contributor Author

@rsc rsc commented Apr 15, 2021

I added some debug prints and am pretty confused.

2021/04/15 11:58:51 Unexpected package creation during export data loading fmt 1 7:
old map[]
new map[fmt:package fmt ("fmt") internal/poll:package poll ("internal/poll") io:package io ("io") io/fs:package fs ("io/fs") os:package os ("os") syscall:package syscall ("syscall") time:package time ("time")]

This all looks fine. Reading the fmt export data will build stub packages for a bunch of its dependencies.

@rsc
Copy link
Contributor Author

@rsc rsc commented Apr 15, 2021

I found it. impliedLoadMode should set NeedImports for NeedExportFile. Will send CL.

@gopherbot
Copy link

@gopherbot gopherbot commented Apr 15, 2021

Change https://golang.org/cl/310512 mentions this issue: go/packages: fix load with NeedTypes but not NeedImports

@seankhliao seankhliao changed the title golang.org/x/tools/go/packages: log.Fatalf inside library routine x/tools/go/packages: log.Fatalf inside library routine Apr 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants