Skip to content
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

Backup and restore go.mod & go.sum during linting #735

Merged
merged 1 commit into from
Jul 12, 2019

Conversation

anoadragon453
Copy link
Member

Every time before sending a PR I like to run ./scripts/build-test-lint.sh to make sure the CI won't complain about anything.

The problem is that this script attempts to install golangci-lint, which causes modifications to go.mod/go.sum. This PR backs up and restores those files before and after linting.

Ideally instead of this hacky backing up/restoring we'd use go gets -mod=readonly option, but that still modifies go.sum. This will be fixed in go 1.13 apparently. golang/go#30667

@anoadragon453 anoadragon453 requested a review from a team July 12, 2019 09:35
@Cnly
Copy link
Contributor

Cnly commented Jul 12, 2019

+1 for this. But is mktemp a better choice than using a .bak file? It minimizes the chance that we overwrite the user's own file. Not sure about it's cross-platform compatibility though.

@anoadragon453
Copy link
Member Author

Yeah, I chose the simple cp and mv commands because they're pretty standard (even on Windows apparently).

We'll remove this when go 1.13 comes anyways, so a little hacky isn't a problem imo.

@anoadragon453 anoadragon453 merged commit d4918b8 into master Jul 12, 2019
@anoadragon453 anoadragon453 deleted the anoa/dont_break_go_mods_on_lint branch July 12, 2019 13:23
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.

2 participants