Note
It seems like there's already a linter that does that, which I couldn't find during the development, so use that one instead. importas
forcealias
is a Go static
analysis tool that enforces
specific import aliases in your codebase. It's especially useful for large
projects or teams that want to maintain consistent import aliasing practices.
- Enforce specific aliases for imports
- Optionally ignore dot (
.
) and underscore (_
) imports - TODO: golangci-lint integration
While it can be used as a standalone linter, do we recommend use it with golangci-lint. (when we add it there, haha)
You can install it via go install
:
go install github.com/ravsii/forcealias/cmd/forcealias@latest
forcealias --force-alias fmt=myfmt ./...
TODO
Flag | Description |
---|---|
--force-alias |
Comma-separated list of importPath=alias mappings |
--ignore-dot |
Skip checking for . imports |
--ignore-underscore |
Skip checking for _ imports |
forcealias --force-alias net/url=defaultUrl,fmt=myfmt --ignore-dot --ignore-underscore ./...
MIT License. See LICENSE for details.
Contributions are welcome! Feel free to open issues or submit pull requests.