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: Removing an unused import path with comments can produce invalid Go code. #15432

Closed
dmitshur opened this issue Apr 25, 2016 · 1 comment

Comments

@dmitshur
Copy link
Contributor

(Tested using latest version of goimports as of right now, commit golang/tools@477d3b9, go version go1.6.2 darwin/amd64.)

Given the following .go file input:

package main

import (
    "encoding/binary"

    // Some comment.
    "fmt"
)

func main() {
    fmt.Println()
}

goimports will try to remove "encoding/binary" and result in the following invalid Go code:

package main

import

// Some comment.
"fmt"

func main() {
    fmt.Println()
}

It should result in valid Go code (but I don't know how it should deal with the comment, exactly).

@dmitshur dmitshur changed the title x/tools/cmd/goimports: Removing an unused import path can mangle comments. x/tools/cmd/goimports: Removing an unused import path with comments can produce invalid Go code. Apr 25, 2016
@gopherbot
Copy link

CL https://golang.org/cl/22415 mentions this issue.

@bradfitz bradfitz added this to the Unreleased milestone Apr 25, 2016
@golang golang locked and limited conversation to collaborators Oct 12, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants