Skip to content

assets/formatters: update the GCI documentation #5892

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

Closed

Conversation

stevekuznetsov
Copy link

@stevekuznetsov stevekuznetsov commented Jun 23, 2025

The gci tool does not format code - it only ensures that import blocks are formatted deterministically, according to the configuration. The previous documentation blurb looks like it may have been copy-pasted from some of the other formatter docs, and was misleading at best.

@ldez please do not close this ... see the proof:

Just using gci does NOT format Go source files:

$ cat .golangci.yaml 
version: "2"
formatters:
  enable:
    - gci
  settings:
    gci:
      custom-order: true
      sections:
        - standard
        - default
        - prefix(k8s.io)
        - prefix(sigs.k8s.io)
        - prefix(github.com/Azure)
        - blank
        - dot
$ go tool golangci-lint fmt
$ git diff
$ go fmt ./...
pkg/config/ev2config/sanitizer/sanitizedconfig.go
pkg/types/resourcegroup.go
pkg/types/shell.go
$ git diff
diff --git a/pkg/config/ev2config/sanitizer/sanitizedconfig.go b/pkg/config/ev2config/sanitizer/sanitizedconfig.go
index 110a582..b479265 100644
--- a/pkg/config/ev2config/sanitizer/sanitizedconfig.go
+++ b/pkg/config/ev2config/sanitizer/sanitizedconfig.go
@@ -10,8 +10,8 @@ type SanitizedCloudConfig struct {
 }
 
 type SanitizedCloudConfigValues struct {
-       CloudName string `json:"cloudName"`
-       KeyVault KeyVaultValues `json:"keyVault"`
+       CloudName string         `json:"cloudName"`
+       KeyVault  KeyVaultValues `json:"keyVault"`
 }
 
 type KeyVaultValues struct {
diff --git a/pkg/types/resourcegroup.go b/pkg/types/resourcegroup.go
index 4076e95..dc83dc6 100644
--- a/pkg/types/resourcegroup.go
+++ b/pkg/types/resourcegroup.go
@@ -18,8 +18,8 @@ import "fmt"
 
 // ResourceGroup represents the resourcegroup containing all steps
 type ResourceGroup struct {
-       Name         string               `json:"name"`
-       Subscription string `json:"subscription"`
+       Name                     string                    `json:"name"`
+       Subscription             string                    `json:"subscription"`
        SubscriptionProvisioning *SubscriptionProvisioning `json:"subscriptionProvisioning,omitempty"`
        // Deprecated: AKSCluster to be removed
        AKSCluster string `json:"aksCluster,omitempty"`
diff --git a/pkg/types/shell.go b/pkg/types/shell.go
index c061617..baec86d 100644
--- a/pkg/types/shell.go
+++ b/pkg/types/shell.go
@@ -26,7 +26,7 @@ type ShellStep struct {
        DryRun        DryRun      `json:"dryRun,omitempty"`
        References    []Reference `json:"references,omitempty"`
        SubnetId      string      `json:"subnetId,omitempty"`
-       ShellIdentity Value    `json:"shellIdentity,omitempty"`
+       ShellIdentity Value       `json:"shellIdentity,omitempty"`
 }
 
 // Reference represents a configurable reference

Adding gofmt DOES:

$ cat .golangci.yaml 
version: "2"
formatters:
  enable:
    - gci
    - gofmt
  settings:
    gci:
      custom-order: true
      sections:
        - standard
        - default
        - prefix(k8s.io)
        - prefix(sigs.k8s.io)
        - prefix(github.com/Azure)
        - blank
        - dot
$ go tool golangci-lint fmt
$ git diff
diff --git a/.golangci.yaml b/.golangci.yaml
index fef60b0..6878cbb 100644
--- a/.golangci.yaml
+++ b/.golangci.yaml
@@ -2,6 +2,7 @@ version: "2"
 formatters:
   enable:
     - gci
+    - gofmt
   settings:
     gci:
       custom-order: true
diff --git a/pkg/config/ev2config/sanitizer/sanitizedconfig.go b/pkg/config/ev2config/sanitizer/sanitizedconfig.go
index 110a582..b479265 100644
--- a/pkg/config/ev2config/sanitizer/sanitizedconfig.go
+++ b/pkg/config/ev2config/sanitizer/sanitizedconfig.go
@@ -10,8 +10,8 @@ type SanitizedCloudConfig struct {
 }
 
 type SanitizedCloudConfigValues struct {
-       CloudName string `json:"cloudName"`
-       KeyVault KeyVaultValues `json:"keyVault"`
+       CloudName string         `json:"cloudName"`
+       KeyVault  KeyVaultValues `json:"keyVault"`
 }
 
 type KeyVaultValues struct {
diff --git a/pkg/types/resourcegroup.go b/pkg/types/resourcegroup.go
index 4076e95..dc83dc6 100644
--- a/pkg/types/resourcegroup.go
+++ b/pkg/types/resourcegroup.go
@@ -18,8 +18,8 @@ import "fmt"
 
 // ResourceGroup represents the resourcegroup containing all steps
 type ResourceGroup struct {
-       Name         string               `json:"name"`
-       Subscription string `json:"subscription"`
+       Name                     string                    `json:"name"`
+       Subscription             string                    `json:"subscription"`
        SubscriptionProvisioning *SubscriptionProvisioning `json:"subscriptionProvisioning,omitempty"`
        // Deprecated: AKSCluster to be removed
        AKSCluster string `json:"aksCluster,omitempty"`
diff --git a/pkg/types/shell.go b/pkg/types/shell.go
index c061617..baec86d 100644
--- a/pkg/types/shell.go
+++ b/pkg/types/shell.go
@@ -26,7 +26,7 @@ type ShellStep struct {
        DryRun        DryRun      `json:"dryRun,omitempty"`
        References    []Reference `json:"references,omitempty"`
        SubnetId      string      `json:"subnetId,omitempty"`
-       ShellIdentity Value    `json:"shellIdentity,omitempty"`
+       ShellIdentity Value       `json:"shellIdentity,omitempty"`
 }
 
 // Reference represents a configurable reference

The `gci` tool does not format code - it only ensures that import blocks
are formatted deterministically, according to the configuration. The
previous documentation blurb looks like it may have been copy-pasted
from some of the other formatter docs, and was misleading at best.

Signed-off-by: Steve Kuznetsov <stekuznetsov@microsoft.com>
@CLAassistant
Copy link

CLAassistant commented Jun 23, 2025

CLA assistant check
All committers have signed the CLA.

@ldez ldez closed this Jun 23, 2025
@ldez ldez added the declined label Jun 23, 2025
@ldez
Copy link
Member

ldez commented Jun 23, 2025

#5891 (comment)

@stevekuznetsov
Copy link
Author

@ldez why are you doing this? I am proving to you that gci does not format the code by itself? You are being quite rude?

@golangci golangci locked as off-topic and limited conversation to collaborators Jun 23, 2025
@ldez
Copy link
Member

ldez commented Jun 23, 2025

@golangci golangci unlocked this conversation Jun 23, 2025
@stevekuznetsov
Copy link
Author

If the file is generated, please let me know the correct place to update instead.

If gci is intended to run a full formatting pass but fails to do so, please open an issue instead.

In either case, aggressively closing what was intended to be a helpful contribution from a user and responding in the way you have is extremely off-putting and makes me entirely uninterested in helping out any longer. I understand that being a maintainer of a popular project is a very taxing and thankless job, and I can sympathize. I hope you are able to assume that people are trying to work with you in good faith, though.

@ldez
Copy link
Member

ldez commented Jun 23, 2025

This PR is locked how it possible for you to comment here 🤔

Edit: I unlocked by mistake.

@golangci golangci locked and limited conversation to collaborators Jun 23, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants