Skip to content

Conversation

@alexandear
Copy link
Contributor

  • Change script/fmt.sh to use the golangci-lint fmt command. Internally, it uses gofmt, gci, gofumpt, goimports simultaneously.
  • Set gci.sections, gofumpt.extra-rules in golangci-lint config and reformat examples.

Inspired by discussion comments in #3938.

@merchantmoh-debug
Copy link
Contributor

@alexandear - Genius. Very good idea.

@codecov
Copy link

codecov bot commented Jan 29, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.45%. Comparing base (1c42933) to head (cde61aa).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3949   +/-   ##
=======================================
  Coverage   92.45%   92.45%           
=======================================
  Files         203      203           
  Lines       14980    14980           
=======================================
  Hits        13850    13850           
  Misses        927      927           
  Partials      203      203           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Collaborator

@gmlewis gmlewis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I may be an old-school Go developer, but I much prefer the grouping of all external imports into a single sorted bunch so that I don't have to visually search multiple bunches to find what I'm looking for.

Is there any way to give the new formatter a flag that preserves this "feature" (in my humble opinion)?

@merchantmoh-debug
Copy link
Contributor

@gmlewis - I can answer that.

Yes, the tool absolutely supports the "Old School" grouping you prefer (Single sorted bunch for all non-standard imports).

Currently, the config defines 3 sections, which forces the split you're seeing:

standard
default (Third-party)
prefix(github.com/google/go-github/) (Internal)
To restore the single "External+Internal" bunch (preserving just the 2-block layout: Standard + Everything Else), we just need to remove the prefix section.

The Config Fix (.golangci.yml):

linters-settings:
gci:
sections:
- standard # Section 1: Standard Lib
- default # Section 2: Everything else (External + Internal sorted together)
# - prefix(github.com/google/go-github/) <--- Removing this merges it into 'default'
This configuration tells the linter to treating everything non-standard as one group, eliminating the "visual search" through multiple bunches.

@alexandear
Copy link
Contributor Author

@gmlewis reverted. By default, gci groups imports into two sections: std and default.

@alexandear alexandear requested a review from gmlewis January 30, 2026 15:00
@gmlewis gmlewis changed the title chore: Format code with golangci-lint fmt chore: Format code with golangci-lint fmt Jan 30, 2026
Copy link
Collaborator

@gmlewis gmlewis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @alexandear and @merchantmoh-debug!
LGTM.
Merging.

@gmlewis gmlewis merged commit 3555113 into google:master Jan 30, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants