Enable medium/low-effort golangci-lint linters#13017
Draft
Conversation
…xing, makezero, testableexamples, wastedassign, usetesting, tparallel, unconvert, intrange, iface - canonicalheader: fix cacheTTL header value to canonical form - embeddedstructfieldcheck: move embedded fields before regular fields in 4 structs - iotamixing: split const blocks mixing iota with non-iota constants - makezero: use make([]T, 0, n) instead of make([]T, n) before appending - testableexamples: add missing Output: comment to ExampleOption_UnwrapOrZero - wastedassign: remove wasted initial assignments in 4 locations - usetesting: replace os.MkdirTemp/os.Setenv with t.TempDir/t.Setenv in tests - tparallel: add t.Parallel() to 8 top-level test functions - unconvert: remove 16 unnecessary type conversions - intrange: convert 3 for loops to use integer range syntax - iface: consolidate identical EditPrompter and Prompt interfaces via type alias Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Rename error variables and types to follow errname linter conventions: - Exported sentinels: ErrXxx - Unexported sentinels: errXxx - Exported error types: XxxError - Unexported error types: xxxError Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: babakks <36728931+babakks@users.noreply.github.com> Agent-Logs-Url: https://github.com/cli/cli/sessions/8cdc9ba4-cdfc-4e14-981c-70b52630b5e5
Copilot
AI
changed the title
[WIP] Add medium and low-effort linters
Enable medium/low-effort golangci-lint linters
Mar 24, 2026
Copilot stopped work on behalf of
babakks due to an error
March 24, 2026 11:26
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Enables the 20 medium/low-effort linters tracked in #12438 and fixes all resulting violations across the codebase.
Linters enabled
Added to
.golangci.ymlwith appropriate settings:canonicalheader,embeddedstructfieldcheck,errname,exhaustive,forbidigo,gochecknoinits,gocyclo,iface,intrange,iotamixing,makezero,mirror,protogetter,recvcheck,testableexamples,tparallel,unconvert,usetesting,wastedassign,whitespaceKey config choices:
exhaustive:default-signifies-exhaustive: true— switches over external enums (e.g.tcell.Key,reflect.Kind) with adefault:branch are considered exhaustiveforbidigo: bansfmt.Print*with message directing to IOStreams;script/excludedgocyclo: threshold 30 with//nolint:gocycloon inherently complex functions (dispatch tables, large interactive flows)Code fixes (~350 violations resolved)
SilentError→ErrSilent,CancelError→ErrCancel,PendingError→ErrPending,ErrClosedPagerPipe→ClosedPagerPipeError,NotInstalled→NotInstalledError, etc.) across ~105 filesIssue,PullRequest,Repositoryvalue-receiver methods promoted to pointer receivers;Client.HTTP()andEditable.Clone()demoted to value receiversfmt.Print*migrated toIOStreams(trustedroot, issue delete, repo garden);iostreams_test.gohelper process exempted via//nolintlock.goandsurveyext/editor.goinit()replaced with IIFEs; test-onlyinit()functions annotated with//nolint:gochecknoinitsgolangci-lint run --fix:whitespace,mirror,protogetter,intrange,unconvert⌨️ Start Copilot coding agent tasks without leaving your editor — available in VS Code, Visual Studio, JetBrains IDEs and Eclipse.