Skip to content

x/tools/cmd/goimports: Removing an unused import path with comments can produce invalid Go code. #15432

@dmitshur

Description

@dmitshur

(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).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions