Skip to content

Fix golangci-lint installation path in dev container #4729

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ ARG VARIANT=1-bullseye
FROM golang:${VARIANT}

RUN go install mvdan.cc/gofumpt@latest
RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.50.0
RUN golangci-lint --version
Comment on lines -8 to -9
Copy link
Contributor Author

Choose a reason for hiding this comment

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

At first, I fixed this line like below:

RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b ./.bin

But golangci-lint binary is not installed to ./.bin for some reason.

So I use postStartCommand in devcontainer.json and it worked.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After some testing, I deleted golangci-lint installation from Dockerfile in 32e7b92.

I found that major golang dev tool is installed with this specify. (dlv golangci-lint golint gomodifytags goplay gopls gotests impl revive staticcheck)
https://github.com/kyu08/lazygit/blob/32e7b92311b933ab76e160d11b622ee190d64023/.devcontainer/devcontainer.json#L15-L17

So we don't need install golangci-lint in Dockerfile.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It would still be good to install the specific version that we are using on CI (2.2.1 at this time), to avoid false positives when golanci-lint gets updated and adds new checks that are enabled by default. This was the very point of introducing the .bin folder.

Of course, if we then later bump the golangci-lint version that we are using, people will still have to fix their installed version manually, but you also have to do that when working locally, and I don't see a good way around that. (We could add a version check to scripts/lint.sh and warn about this, but this wouldn't help with the lint-on-save function in vscode, which is the main use of linting for me.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see.
Then go tool may be suitable solution.

It allows us to manage versions of tools which are written in Go using go.mod.
So we can unify versions of dev tools such as golang-lint or gofumpt easily.

I'll take some time to try it out next week.

Copy link
Collaborator

Choose a reason for hiding this comment

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

No experience with that, but on https://golangci-lint.run/welcome/install/ it says We don't recommend using go tool. They don't really say why, though.

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is a great idea. I made a separate PR (#4733) to take this a bit further and also make it work for lint-on-save in vscode. I didn't test if this works in a dev container, but it should; if you have time to test this, that would be great.

Copy link
Contributor Author

@kyu08 kyu08 Jul 13, 2025

Choose a reason for hiding this comment

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

Thanks.

if you have time to test this, that would be great.

Just to clarify, are you asking me to test #4733 specifically, or to test changing the make lint target to go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.2.1 run?

If it's second option, I confirmed it worked.

This is a head of the command.
 2025-07-13 at 22 53 52

And this is the tail of it.

 2025-07-13 at 22 54 02

About your PR, it'll take a while because I'm not familiar with VSCode. Maybe sometime in next week.

And how should we divide the roles between this PR and your
PR(#4733 )?

Copy link
Collaborator

Choose a reason for hiding this comment

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

No, I meant to test #4733. If I'm not missing anything, that PR can completely replace this one.

Copy link
Contributor Author

@kyu08 kyu08 Jul 13, 2025

Choose a reason for hiding this comment

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

OK.
If you don't mind, could you add me as co-author of your first commit of #4733?
I'd be happy if my contribution remained in a clear and visible form.

Anyway, I'll take time for it next week.

Copy link
Collaborator

Choose a reason for hiding this comment

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

If you don't mind, could you add me as co-author of your first commit of #4733?

Sure. Let me know if you'd like to appear with a different name or email address than what I added. Also mentioning you in the PR description now.


# [Optional] Uncomment this section to install additional OS packages.
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ format:

.PHONY: lint
lint:
./scripts/lint.sh
go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.0.2 run

# For more details about integration test, see https://github.com/jesseduffield/lazygit/blob/master/pkg/integration/README.md.
.PHONY: integration-test-tui
Expand Down
Loading