美文网首页
附1 go get 私有仓库 常见错误汇总

附1 go get 私有仓库 常见错误汇总

作者: cn華少 | 来源:发表于2020-06-20 16:06 被阅读0次

    本系列文章均为学习过程中记录的笔记,欢迎和我一起来学习Go语言。

    全文使用环境如下:

    • Go语言版本:1.14
    • 操作系统:deepin
    • 使用工具:Goland开发工具

    我在日常编写项目时总是喜欢使用自己的公共工具组件,go语言1.11版本以后增加了mod功能,这就可以将自己的公共组件直接从仓库里面拉取下来了,但是拉取的过程注定是存在天坑的,以下就是我在使用该功能时汇总的一些常见错误和解决方案,希望能给大家带来一些帮助。

    执行go get gitee.com/xxx/xxxxxx.git常见错误汇总

    错误1

    status 128:
            fatal: unable to connect to gitee.com:
            gitee.com[0: 212.64.62.174]: errno=No such file or directory
    
    造成原因:

    需要用https才能读到数据

    解决方案:

    执行如下命令

    git config --global url."git@gitee.com:".insteadOf "https://gitee.com/"
    

    或在git的~/.gitconfig文件中增加配置

    [url "git@gitee.com:"]
        insteadOf = https://gitee.com/
    

    错误2

    go get gitee.com/xxx/xxxxxx.git: module gitee.com/xxx/xxxxxx.git: reading https://mirrors.aliyun.com/goproxy/gitee.com/xxx/xxxxxx.git/@v/list: 504 Gateway Timeout
    
    造成原因:

    使用了预设置的GOPROXY参数

    解决方案:

    go版本1.14及以后,根据自己的地址修改下面的命令并执行。授权特定地址不再使用GOPROXY和CHECKSUM等逻辑

    set GOPRIVATE=gitee.com/xxxx,gitee.com/demo,*.gitee.com
    

    错误3

    Please make sure you have the correct access rights
    and the repository exists.
    # cd .; git ls-remote ssh://gitee.com/xxx/xxxxxx.git
    Permission denied, user: 'lz239'
    fatal: Could not read from remote repository.
    
    造成原因:

    当前git账号无权限

    解决方案

    修改~/.gitconfig文件中的

    [user]
        name = 用户名
        email = 账号邮箱
    
    本文声明:

    知识共享许可协议
    本作品由 cn華少 采用 知识共享署名-非商业性使用 4.0 国际许可协议 进行许可。

    文章中凡是涉及的代码均在Gitee与GitHub上了,有需要的可以通过下面的地址下载。
    [图片上传失败...(image-4b69d8-1592640396721)]

    [图片上传失败...(image-849061-1592640396721)]

    相关文章

      网友评论

          本文标题:附1 go get 私有仓库 常见错误汇总

          本文链接:https://www.haomeiwen.com/subject/ddfgxktx.html