Go get拉取AWS CodeCommit私有模块失败,求解决方案
问题描述
尝试通过Go模块拉取AWS CodeCommit私有代码库时失败,执行命令:
go get git-codecommit.region.amazonaws.com/version/repo/util_service.git
返回错误:
go: module git-codecommit.region/repos/util_service.git: git ls-remote -q origin in D:\workArea\pkg\mod\cache\vcs\a7336f14e81412deff871e645affca79a601f7: exit status 128:
fatal: unable to connect to git-codecommit.region:
git-codecommit.region[0: 12.34.56.123]: errno=Unknown error
环境信息:Golang 1.20、Windows系统、VSCode编辑器,已尝试相关方案未解决。
解决办法
修正Git的CodeCommit URL映射
将CodeCommit的旧格式URL映射到正确的v1端点(替换<你的区域>为实际区域,如us-east-1):git config --global url."https://git-codecommit.<你的区域>.amazonaws.com/v1/repos/".insteadOf "git-codecommit.<你的区域>.amazonaws.com/version/repo/"验证AWS凭证有效性
- 执行
aws configure确认Access Key、Secret Key、默认区域配置正确 - 检查
C:\Users\<你的用户名>\.aws\credentials和C:\Users\<你的用户名>\.aws\config文件是否存在且内容无误
- 执行
配置Git使用AWS凭证助手
让Git通过AWS CLI自动处理CodeCommit认证:git config --global credential.helper "!aws codecommit credential-helper $@" git config --global credential.UseHttpPath true先验证Git连通性
用Git克隆命令测试仓库是否可访问,排除Go模块的影响:git clone https://git-codecommit.<你的区域>.amazonaws.com/v1/repos/util_service克隆成功后再重新执行
go get命令。排查网络问题
- 关闭VPN或代理,尝试直连
- 检查Windows防火墙是否允许Git、Go程序访问网络
- 执行
ping git-codecommit.<你的区域>.amazonaws.com测试端点可达性
内容的提问来源于stack exchange,提问作者Udayakumar
相关产品推荐
相关产品推荐

