daixiang0 / gci

GCI, a tool that control golang package import order and make it always deterministic.
BSD 3-Clause "New" or "Revised" License
433 stars 62 forks source link

Support all stdlib packages (Fix: Infinite repair loop) #174

Closed mvrahden closed 8 months ago

mvrahden commented 1 year ago

The gci fixes infinitely for newer stdlib packages. This original (No.1):

import (
    "context"
    "encoding/json"
    "errors"
    "slices" // <<---
    "testing"

    "github.com/aws/aws-lambda-go/events"
    "github.com/stretchr/testify/require"
)

becomes (No.2):

import (
    "context"
    "encoding/json"
    "errors"
    "testing"

    "github.com/aws/aws-lambda-go/events"
    "github.com/stretchr/testify/require"
    "slices" // <<---
)

becomes (No.3):

import (
    "context"
    "encoding/json"
    "errors"
    "testing"

    "slices" // <<---

    "github.com/aws/aws-lambda-go/events"
    "github.com/stretchr/testify/require"
)

and then becomes No.2 again, and will then never stop fixing. This is problematic in golangci-lint.

Can this please be fixed?

daixiang0 commented 1 year ago

Could you provide the issue version of GCI?

mvrahden commented 1 year ago

Hi, it is version v0.11.0 of GCI. I was using it in combination with golangci-lint v1.54.2.

andriisoldatenko commented 1 year ago

Looks like it fixed in https://github.com/daixiang0/gci/issues/174 https://github.com/daixiang0/gci/pull/163/files#diff-74342d74a10a1ff588f6ae1b4e02e5869a759bcdad74b2f41756252ef024b72eR146

I've tested with golang 1.21.4 and gci version 0.11.2 and it works like a charm.

daixiang0 commented 8 months ago

Close as fixed.

ccoVeille commented 8 months ago

Looks like it fixed in https://github.com/daixiang0/gci/issues/174 https://github.com/daixiang0/gci/pull/163/files#diff-74342d74a10a1ff588f6ae1b4e02e5869a759bcdad74b2f41756252ef024b72eR146

I've tested with golang 1.21.4 and gci version 0.11.2 and it works like a charm.

I think you meant #163 because #174 is this one.

But it's a great thing. Thanks for spotting it was fixed. I was following this ticket and not 163