Various gopls lint cleanups for package `git` by bk2204 · Pull Request #6211 · git-lfs/git-lfs · GitHub
Skip to content

Various gopls lint cleanups for package git - #6211

Merged
chrisd8088 merged 2 commits into
git-lfs:mainfrom
bk2204:git-pkg-cleanups
Mar 4, 2026
Merged

chrisd8088 merged 2 commits into
git-lfs:mainfrom
bk2204:git-pkg-cleanups

Conversation

@bk2204

@bk2204 bk2204 commented Mar 2, 2026 •

Copy link
Copy Markdown
Member

I was in the git package and noticed that my editor was providing me with some linting suggestions, which apparently come from gopls, the Go LSP. I've fixed the two major issues that I found there, which can be listed with gopls check --severity=hint ./git/*.go.

I did not fix every issue, however. I skipped removing the unused functions which implement a complete interface and I only chose to fix items that were at least several Go releases old (I think the latest version required is Go 1.21) in order to reduce the burden on downstream maintainers.

This PR contains independent, logical, bisectable commits each with their own commit message, and as such is best reviewed commit by commit.

We have several pieces of code that open-code `slices.Contains`.  We did
not originally write this code this way since our codebase precedes the
`slices` package and, for that matter, generics in Go, but this is now a
easier and simpler way to write this code and gopls suggests we
modernize, so change it.

Remove our own version of this code as well, since it's just a duplicate
of the standard function.
@bk2204
bk2204 marked this pull request as ready for review March 2, 2026 21:42
@bk2204
bk2204 requested a review from a team as a code owner March 2, 2026 21:42

@chrisd8088 chrisd8088 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you, this looks like a nice bit of code cleanup!

I had one pair of minor suggestions about variable names (natch!), but aside from that this looks great, thank you.

Comment thread git/git.go Outdated
Comment thread git/git.go Outdated
@chrisd8088 chrisd8088 added the go Pull requests that update Go code label Mar 4, 2026
gopls warns us that some of this code can be more easily and simply
written using `strings.Cut`.  Update our parsing code to use this
function, which appeared in Go 1.18, to simplify our code somewhat.
@bk2204
bk2204 force-pushed the git-pkg-cleanups branch from 3c045a2 to 810588a Compare March 4, 2026 15:31

@chrisd8088 chrisd8088 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you again!

@chrisd8088
chrisd8088 merged commit f4ebf5f into git-lfs:main Mar 4, 2026
19 of 20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

go Pull requests that update Go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants