Skip to content
This repository has been archived by the owner on Jun 17, 2024. It is now read-only.

Format and lint go imports with gci #85

Merged
merged 1 commit into from
Oct 13, 2023

Conversation

andrewwdye
Copy link
Contributor

@andrewwdye andrewwdye commented Oct 10, 2023

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:

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:

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"
)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants