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

Support Golang major versions #2561

Closed

Conversation

arjen-ag5
Copy link

Golang has a special treatment of major versions. If you go from v1.x.x to v2.x.x you are supposed to put all your code in a v2 directory in the root of the repository. This break pre-commit because pre-commit tries to do a go install ./... in the root, this fails because now the go.mod file is missing. See this repository for example: https://github.com/nicksnyder/go-i18n.

This patch checks if there is a go.mod in the root of the project, if it is not it will scan all subdirectories matching the v[0-9]+ pattern until it finds one containing a go.mod file. This will be the cwd for the install command.

For reference:
https://go.dev/doc/modules/major-version

@asottile
Copy link
Member

the docs you linked are for a subpath install. pre-commit only supports the convention of the project being at the root. guessing is a surprising behavior that I can't support

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants