Skip to content

x/tools/cmd/goimports: do not make grouped imports non-grouped when removing #18051

@xh3b4sd

Description

@xh3b4sd

What did you do?

I have this file.

package main

func main() {
	s := []string{}
	ss := strings.Join(s, ",")

	fmt.Printf("%#v\n", ss)
}

Running goimports does this.

package main

import (
	"fmt"
	"strings"
)

func main() {
	s := []string{}
	ss := strings.Join(s, ",")

	fmt.Printf("%#v\n", ss)
}

Removing the line where the fmt package is used does this when goimports is run.

package main

import "strings"

func main() {
	s := []string{}
	ss := strings.Join(s, ",")

}

What did you expect to see?

I would like the import statement always to be "multiple", no matter how many imports the package has.

import (
	....
)

What did you see instead?

On packages suddenly having only one imported package, the import statement is "single". I am a little OCDish on this one. Diffs would be way more nicer and the import statements across files and packages would be way more consistent when the import statement would have always be the same form.

Cheers, Tim.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions