Skip to content

Maybe inline diff tool into golangci-lint #362

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
jirfag opened this issue Jan 20, 2019 · 5 comments · Fixed by #5301
Closed

Maybe inline diff tool into golangci-lint #362

jirfag opened this issue Jan 20, 2019 · 5 comments · Fixed by #5301
Labels
enhancement New feature or improvement

Comments

@jirfag
Copy link
Contributor

jirfag commented Jan 20, 2019

Got a few issues that "diff" isn't installed, especially on windows. We can inline it's code into golangci-lint

@alyandon
Copy link

alyandon commented Apr 30, 2019

That would be nice to have for Windows. However, most Windows developers will have Git installed and adding the "[DRIVE]:\program files\git\usr\bin" to your path fixes the problem since Git bundles a version of diff.

@tpounds tpounds added the enhancement New feature or improvement label Oct 5, 2019
@Gregory-Ledray
Copy link

I ran into this while trying to fix the Git Diff problem, which was after a few other problems I had with Gitlab CI / CD pipelines. I wrote some Powershell scripts someone can use to automate this process:

installGolangciLint.ps1

Invoke-WebRequest -Uri https://github.com/golangci/golangci-lint/releases/download/v1.23.6/golangci-lint-1.23.6-windows-amd64.zip -OutFile ".\download.zip"
Expand-Archive .\download.zip -DestinationPath .\download -Force
$p = Resolve-Path .\download\golangci-lint-1.23.6-windows-amd64
$Env:Path += ";$p"
[Environment]::SetEnvironmentVariable("Path", $env:Path, [System.EnvironmentVariableTarget]::Machine)

installChoco.ps1

Set-ExecutionPolicy Bypass -Scope Process -Force
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072
iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))

installGitWithChoco.ps1

choco install git -y -params '"/GitAndUnixToolsOnPath"'
# We must make sure the tools directory is added to PATH. By default this is the correct directory
# And although the above command is supposed to add it to Path, without this line golangci-lint fails
$Env:Path += ";C:\Program Files\Git\usr\bin"
[Environment]::SetEnvironmentVariable("Path", $env:Path, [System.EnvironmentVariableTarget]::Machine)

I then run the equivalent of golangci-lint run --fix and that works. Proof of success is in my CI/CD Job's results:
https://gitlab.com/polyapp-open-source/poly/-/jobs/452889033

The full .gitlab-ci.yml file (Ctrl+F for "poly_demo_lint_windows" which has the right Job) can be found here:
https://gitlab.com/polyapp-open-source/poly/-/blob/c7075edc23eb93f765391aa4d00d6aec78b4939c/.gitlab-ci.yml

I hope this helps someone else or better yet golangci-lint offers a better installation process (like using chocolatey) for Windows users. My use-case for running golangci-lint on Windows is that my Go code manipulates paths, and therefore I want to run my CI/CD pipelines on Windows. I also want to support Windows servers for deployment of my app, and this 'proves' the app works the same there as on Linux.

@stale
Copy link

stale bot commented Mar 5, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale No recent correspondence or work activity label Mar 5, 2021
@ldez ldez removed the stale No recent correspondence or work activity label Mar 5, 2021
@stale
Copy link

stale bot commented Mar 30, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale No recent correspondence or work activity label Mar 30, 2022
@ldez ldez removed the stale No recent correspondence or work activity label Mar 30, 2022
@OlegSchwann

This comment was marked as off-topic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or improvement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants