Open artuross opened 3 weeks ago
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):
github.com/testcontainers/testcontainers-go
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:
gofumpt
import tc "github.com/testcontainers/testcontainers-go"
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 packagetestcontainers
):should be aliased to
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: