<#85 Format and lint go imports with gci> Pull req...
# flyte-github
a
#85 Format and lint go imports with gci Pull request opened by andrewwdye Go imports are formatted inconsistently throughout the flyteorg codebase. In particular,
goimports
orders imports within a block and optionally breaks them into standard, default, and third party packages, but it does not reformat already broken import blocks. There is a long discussion about this behavior here. As an alternative
gci
will ensure that go imports are grouped into exactly the sections requested. This change • updates
make goimports
to run
gci
to format goimports into three sections: standard, default, and flyteorg • adds
gci
as a linter for
golangci-lint
, which is run using
make run
For an example of the formatted output of
make goimports
, see this dry run for flyteplugins For instance, before:
Copy code
import (
	"context"
	"testing"

	"github.com/flyteorg/flyte/flyteplugins/go/tasks/pluginmachinery/core"
	"github.com/flyteorg/flyte/flyteplugins/go/tasks/pluginmachinery/core/mocks"
	"gotest.tools/assert"
)
After:
Copy code
import (
	"context"
	"testing"

	"gotest.tools/assert"

	"github.com/flyteorg/flyte/flyteplugins/go/tasks/pluginmachinery/core"
	"github.com/flyteorg/flyte/flyteplugins/go/tasks/pluginmachinery/core/mocks"
)
flyteorg/boilerplate ✅ All checks have passed 2/2 successful checks