英文:
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论