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

Alias imported package to match the package name #305

Open
artuross opened this issue Jun 12, 2024 · 0 comments
Open

Alias imported package to match the package name #305

artuross opened this issue Jun 12, 2024 · 0 comments

Comments

@artuross
Copy link

When the import path doesn't match the package name, it's a good idea to alias the import to be more explicit.

Here's an example with github.com/testcontainers/testcontainers-go (which defines a package testcontainers):

import "github.com/testcontainers/testcontainers-go"

should be aliased to

import testcontainers "github.com/testcontainers/testcontainers-go"

Both imports are equivalent, because in both files, package can be accessed as testcontainers.

On the other hand, if the package is already aliased like in the following example, gofumpt should not change the alias:

import tc "github.com/testcontainers/testcontainers-go"
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

No branches or pull requests

1 participant