golang module 私有仓库

前言

开发环境下的 gitlab https 没有认证,使用ssh一直提示输入密码,所以需要使用 access token的方式,总之关键点就是 access token,https和ssl,还有默认配置文件
注意: 以下环境实在 ubuntu 上操作的,其他环境可能略有不同

  • 创建 ~/.gitconfig 文件,内容如下
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    [http]
    # 禁用ssl验证
    sslverify = false
    extraheader = PRIVATE-TOKEN: balabababa
    [user]
    name = ginta
    email = [email protected]
    [url "https://ginta:[email protected]/"]
    insteadOf = https://gitlab.devdd.com/
    [credential]
    helper = store

执行

1
2
go env -w GOINSECURE="gitlab.devdd.com/*"
go env -w GOPRIVATE=https://ginta:[email protected]/devdd

执行完毕之后查看 go env 有如下显示

1
2
3
4
GOINSECURE='gitlab.devdd.com/*'
GONOPROXY='https://ginta:[email protected]/devdd'
GONOSUMDB='https://ginta:[email protected]/devdd'
GOPRIVATE='https://ginta:[email protected]/devdd'

golang module 私有仓库

https://ginta.top/2024/07/24/1045/

作者

Ginta

发布于

2024-07-24

更新于

2024-07-25

许可协议

评论