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

Closed
nasitra opened this issue Jul 7, 2017 · 1 comment
Closed

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

nasitra opened this issue Jul 7, 2017 · 1 comment
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@nasitra
Copy link

nasitra commented Jul 7, 2017

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

1.8.3

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

windows/amd64

What did you do?

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

package main

func main() {
  fmt.Println("hello")
}

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() {
        fmt.Println("hello")
}

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]:
golang.org/x/tools/imports.fixImports.func2(0xc04205a0c8, 0xc04202ec00, 0x616eb5, 0x10, 0xc0420311e4, 0x3, 0xc042058e70)
        C:/XXX/go/src/golang.org/x/tools/imports/fix.go:257 +0x41
created by golang.org/x/tools/imports.fixImports
        C:/XXX/go/src/golang.org/x/tools/imports/fix.go:268 +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 The path to resolution is known, but the work has not been done. label Jul 7, 2017
@gopherbot
Copy link
Contributor

CL https://golang.org/cl/47810 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.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

3 participants