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/cmd/goimports: panic on reading from stdin on Windows #20941

nasitra opened this issue Jul 7, 2017 · 1 comment

x/tools/cmd/goimports: panic on reading from stdin on Windows #20941

nasitra opened this issue Jul 7, 2017 · 1 comment


Copy link

@nasitra nasitra commented Jul 7, 2017

What version of Go are you using (go version)?


What operating system and processor architecture are you using (go env)?


What did you do?

Make the code(hello.go) without importing 'fmt' package

package main

func main() {

Then run goimports reading the code from stdin

type hello.go | goimports

What did you expect to see?

Output code text with importing 'fmt' package

package main

import "fmt"

func main() {

What did you see instead?

Runtime error occurred.

panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x8 pc=0x5a2dc1]

goroutine 18 [running]:, 0xc04202ec00, 0x616eb5, 0x10, 0xc0420311e4, 0x3, 0xc042058e70)
        C:/XXX/go/src/ +0x41
created by
        C:/XXX/go/src/ +0x676

Because of the error, I can't use goimports in GoSublime for Sublime Text 3 on Windows.

I tried the local change (it works), but it seems that this problem is caused by a different result of dirPackageInfoFile() for stdin between Windows and other platforms.

@gopherbot gopherbot added this to the Unreleased milestone Jul 7, 2017
@bradfitz bradfitz self-assigned this Jul 7, 2017
@bradfitz bradfitz added the NeedsFix label Jul 7, 2017
Copy link

@gopherbot gopherbot commented Jul 7, 2017

CL mentions this issue.

@golang golang locked and limited conversation to collaborators Jul 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.