Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: sort import statements #41

Merged
merged 1 commit into from
Apr 26, 2023
Merged

Conversation

0xHansLee
Copy link
Contributor

@0xHansLee 0xHansLee commented Apr 26, 2023

There are some unsorted import statements, so I sorted them using goimports-reviser.

> goimports-reviser -rm-unused ./...

Currently, goimports do not sort import statements consistently (it is well-known issue: golang/go#20818).

There are many other alternatives, and I tried to use goimports-reviser since it works well as we desired and they also have linter for sorting import statements (we can add linter to CI in the future as well).

FYI, you can configure goimports-reviser in IntelliJ as described here.

@0xHansLee 0xHansLee requested a review from a team April 26, 2023 01:07
Copy link

@chokobole chokobole left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@seolaoh seolaoh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@0xHansLee 0xHansLee merged commit 2e2b17e into dev Apr 26, 2023
@0xHansLee 0xHansLee deleted the chore/sort-import-statements branch April 26, 2023 04:44
@0xHansLee
Copy link
Contributor Author

Let me share how to set goimports-reviser formatter on save in VS code.
(I'm not sure this is the best way, but I want to share how to figure it out. If you have any better idea, please leave your tips for everyone.)

I used run on save extenstion to run goimports-reviser command on save.
This is the configuration added to settings.json

{
    // ...
    "emeraldwalk.runonsave": {
        "commands": [
            {
                "match": ".*",
                "cmd": "$HOME/go/bin/goimports-reviser -rm-unused ${file}"
            },
        ]
    }
    // ...
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants