incu6us / goimports-reviser

Right imports sorting & code formatting tool (goimports alternative)
MIT License
607 stars 72 forks source link

Single import becomes a list of imports #144

Closed Ericwww closed 10 months ago

Ericwww commented 11 months ago

Hi @incu6us

Sorry to bother you again.

I would like to use goimports-reviser as a replacement for goimports.

But at the single import situation, their behavior is inconsistent.

For example,

package testdata

import "log"

func AAA() {
    log.Print("aaa")
}

When I run goimports, the result is the same as above.

But when I run goimports-reviser, the result will be

package testdata

import (
    "log"
)

func AAA() {
    log.Print("aaa")
}

A single import becomes a list of imports, but there is only one import in the list.

I think the problem is at reviser/file.go:378, function: #rebuildImports

Ericwww commented 11 months ago

I'm trying to fix it. All unit tests (including the ones I added) passed. But I'm not sure if this modification is correct.

incu6us commented 11 months ago

thanks @Ericwww I'll check

l2cup commented 10 months ago

Can i bump this? We're blocked on upgrading our version until this this is fixed.

Thanks 🙏

Ericwww commented 10 months ago

Hi @l2cup, I'm not the owner of this repository.

I just submitted my new code. PR: #145 I think such logic should be more elegant than before and can cover more scenes. I have passed all the checks except Build.

If @incu6us thinks there is no problem, I think this issue can be closed. 😃 😃

incu6us commented 10 months ago

thanks for your efforts @Ericwww it is merged and available in v3.6.4