Skip to content

x/tools/cmd/goimports: ability to disable pkg renaming #23004

@pkieltyka

Description

@pkieltyka

go version go1.9.2 darwin/amd64 and golang.org/x/tools/cmd/goimports @ 0444735

For packages that manage versioning through import paths, such as "upper.io/db.v3" or "google.golang.org/api/youtube/v3" goimports will import these packages as:

import (
  db "upper.io/db.v3"
  youtube "google.golang.org/api/youtube/v3"
)

although it may be a useful hint to readers to see the explicit package name for the path, my preference is to use package renaming only when I'm actually renaming a package, and I tend to understand the packages Im using and their name as db or youtube.

I've determined findImport() in https://github.com/golang/tools/blob/master/imports/fix.go#L734 to be the function that provides a rename functionality, later set here: https://github.com/golang/tools/blob/master/imports/fix.go#L258-L260

Is there any interest to have the ability for the goimports cli to have a flag -norename that will turn off automatic package renames on import as described above? if so, I'm happy to work on a submission. I understand this is only an aesthetic suggestion and I've already forked the project for my own purposes, but I know others on my team felt similarly so I'm seeing if we can add this as a dedicated option.

thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeToolsThis label describes issues relating to any tools in the x/tools repository.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions