预提交钩子抛出错误 https://github.com/dnephin/pre-commit-golang

huangapple go评论90阅读模式
英文:

Pre commit hook throwing error https://github.com/dnephin/pre-commit-golang

问题

检查是否添加了大文件..............................................通过
不要提交到分支...................................................通过
修复文件末尾.........................................................通过
修剪尾随空格.................................................通过
检查Yaml...............................................................通过
goimports................................................................失败

  • 钩子ID:goimports
  • 退出代码:1
    找不到可执行文件goimports

运行Go预提交钩子时出现上述错误。我尝试安装了golang.org/x/tools/cmd/goimports,但仍然出现错误。有什么建议可以解决这个问题吗?

英文:
Check for added large files..............................................Passed
Don't commit to branch...................................................Passed
Fix End of Files.........................................................Passed
Trim Trailing Whitespace.................................................Passed
Check Yaml...............................................................Passed
goimports................................................................Failed
- hook id: goimports
- exit code: 1
Executable `goimports` not found

When running Go pre hook commit I am getting the above error. I did try to install golang.org/x/tools/cmd/goimports but it still gives me the error. Any suggestion how to resolve this will be appreciated

答案1

得分: 1

看起来goimports需要在pre-commit之外进行安装和管理(逃离正常的支持路径)。

根据自述文件中的说明:

  • go-imports - 运行goimports,需要安装golang.org/x/tools/cmd/goimports

所以你需要确保该工具已安装并在全局范围内可用。

英文:

it looks like goimports needs to be installed and managed externally to pre-commit (escaping the normal supported pathway)

from the readme

> - go-imports - Runs goimports, requires golang.org/x/tools/cmd/goimports

so you'll need to make sure that tool is installed and globally available

huangapple
  • 本文由 发表于 2021年11月4日 01:07:55
  • 转载请务必保留本文链接:https://go.coder-hub.com/69828981.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定