Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Chore] Golang import grouping by package #2567

Open
1 of 2 tasks
Eikykun opened this issue Nov 25, 2024 · 3 comments · May be fixed by #2613
Open
1 of 2 tasks

[Chore] Golang import grouping by package #2567

Eikykun opened this issue Nov 25, 2024 · 3 comments · May be fixed by #2613
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers lint

Comments

@Eikykun
Copy link
Contributor

Eikykun commented Nov 25, 2024

Search before asking

  • I had searched in the issues and found no similar feature requirement.

Description

Can we group and sort the imports in Go?

For example:
before:
https://github.com/ray-project/kuberay/blob/master/ray-operator/controllers/ray/raycluster_controller.go#L3-L50
after:

import (
	"context"
	errstd "errors"
	"fmt"
	"os"
	"reflect"
	"runtime"
	"strconv"
	"strings"
	"time"

	"github.com/go-logr/logr"
	routev1 "github.com/openshift/api/route/v1"
	batchv1 "k8s.io/api/batch/v1"
	corev1 "k8s.io/api/core/v1"
	networkingv1 "k8s.io/api/networking/v1"
	rbacv1 "k8s.io/api/rbac/v1"
	"k8s.io/apimachinery/pkg/api/errors"
	"k8s.io/apimachinery/pkg/api/meta"
	"k8s.io/apimachinery/pkg/api/resource"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	k8sruntime "k8s.io/apimachinery/pkg/runtime"
	"k8s.io/client-go/discovery"
	"k8s.io/client-go/rest"
	"k8s.io/client-go/tools/record"
	"k8s.io/utils/ptr"
	ctrl "sigs.k8s.io/controller-runtime"
	"sigs.k8s.io/controller-runtime/pkg/builder"
	"sigs.k8s.io/controller-runtime/pkg/client"
	"sigs.k8s.io/controller-runtime/pkg/controller"
	"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
	"sigs.k8s.io/controller-runtime/pkg/manager"
	"sigs.k8s.io/controller-runtime/pkg/predicate"
	"sigs.k8s.io/controller-runtime/pkg/reconcile"

	configapi "github.com/ray-project/kuberay/ray-operator/apis/config/v1alpha1"
	rayv1 "github.com/ray-project/kuberay/ray-operator/apis/ray/v1"
	"github.com/ray-project/kuberay/ray-operator/controllers/ray/batchscheduler"
	"github.com/ray-project/kuberay/ray-operator/controllers/ray/common"
	"github.com/ray-project/kuberay/ray-operator/controllers/ray/expectations"
	"github.com/ray-project/kuberay/ray-operator/controllers/ray/utils"
	"github.com/ray-project/kuberay/ray-operator/pkg/features"
)

During development, my editor automatically handles these tasks. Perhaps we can check the grouping order of imports in the GitHub workflow.

Use case

�Code style

Related issues

none

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!
@Eikykun Eikykun added enhancement New feature or request triage labels Nov 25, 2024
@kevin85421
Copy link
Member

If there is a linter available to check this, we can add it.

@kevin85421 kevin85421 added lint good first issue Good for newcomers and removed triage labels Nov 27, 2024
@win5923
Copy link
Contributor

win5923 commented Dec 4, 2024

Maybe gci is a good choice.
https://golangci-lint.run/usage/linters/#gci

@kevin85421
Copy link
Member

Assign to @win5923

@win5923 win5923 linked a pull request Dec 5, 2024 that will close this issue
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers lint
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants