-
-
Notifications
You must be signed in to change notification settings - Fork 910
Closed
Labels
Description
Go 1.16 now rejects empty go.mod files (c.f. golang/go@d4986e0). This means that golang hooks cannot be installed anymore:
$ pre-commit install-hooks
[INFO] Initializing environment for local.
[INFO] Installing environment for local.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
An unexpected error has occurred: CalledProcessError: command: ('/usr/local/bin/go', 'get', './...')
return code: 1
expected return code: 0
stdout: (none)
stderr:
go: no module declaration in go.mod. To specify the module path:
go mod edit -module=example.com/mod
Check the log at /Users/rdraoui/.cache/pre-commit/pre-commit.log
I could get it to work by changing pre_commit/resources/empty_template_go.mod from an empty file to:
module example/mod
But I'm not all that familiar with how modules work in different Go versions, so maybe making that change has some other implications that I don't know about. This Go Wiki entry seems to suggest that empty go.mod files are legal, but maybe it's outdated... (c.f: #1428 (review))
The fix is compatible with Go 1.15.
I tried validating the fix by running the test suite (pytest tests -k golang), but I can't get it to pass with Go 1.15 and current master branch either.