Formatting a single import
What version of GCI are you using?
v0.13.6 (via golangci-lint)
Details
Currently, single-imports seem to be ignored.
package main
import "time"
formats as:
package main
import "time"
and
package main
import (
"time"
)
formats as:
package main
import (
"time"
)
As shown above, the style of single imports is unchanged. It would be nice to have a option to enable/disable groups for single imports for more uniformity.
Perhaps with an option called single-import-style which can be one of inline, group or ignore (this can be the default for backwards compatibility).
You can use the grouper linter to achieve this: https://github.com/leonklingele/grouper#available-flags
grouper -import-require-single-import -import-require-grouping ./...
It's also part of golangci-lint: https://github.com/golangci/golangci-lint/blob/v2.3.0/.golangci.reference.yml#L1777-L1782
Thanks, @leonklingele .
The import-require-grouping is the closest to what I pictured, yet it enforces the opposite style. XD.
I would rather have single imports be inlined.
E.g.
import "time"
Not:
import (
"time"
)
And grouper is a linter (without autofix) unlike gci which automatically formats the imports. In any case, it's a good enough workaround. I'll be using it for now as it makes the single imports consistent (despite my style preference).