mvdan / gofumpt

A stricter gofmt
https://pkg.go.dev/mvdan.cc/gofumpt
BSD 3-Clause "New" or "Revised" License
3.15k stars 110 forks source link

proposal: Remove redundant package aliases from import blocks #296

Closed adamroyjones closed 4 months ago

adamroyjones commented 4 months ago

I noticed that

package main

import (
    foo "gofumpt-ex/foo"
)

func main() {
    foo.Foo("goodbye, world!")
}

wasn't being simplified to

package main

import (
    "gofumpt-ex/foo"
)

func main() {
    foo.Foo("goodbye, world!")
}

when the package name of "gofumpt-ex/foo" is "foo".

I thought it might be a nice addition, and I wanted to have a bit of a poke around in gofumpt, and so I've this branch.

If this is an unwelcome change, please don't be shy in saying so.

mvdan commented 4 months ago

I thought it might be a nice addition, and I wanted to have a bit of a poke around in gofumpt, and so I've this branch.

If this is an unwelcome change, please don't be shy in saying so.

My comment aside, thanks for contributing, and for being understanding :)

adamroyjones commented 4 months ago

I've gone ahead and put together a proposed ST1024 check here: https://github.com/dominikh/go-tools/pull/1497.

Thanks again for the quick response (and, on a totally unrelated note, for the work on encoding/json/v2—I'm only on the sidelines, watching, but it's exciting to see).