1 申请令牌
方法1:具体项目下申请:
方法2:全局申请
2 获取token
3 下载代码
package main
import (
"fmt"
"os"
"github.com/go-git/go-git/v5"
)
func main() {
_, err := git.PlainClone("/tmp/foo", false, &git.CloneOptions{
URL: "https://username:token@gitlab.tencent.net/dba/job.git",
Progress: os.Stdout,
})
if err != nil {
panic(err)
}
fmt.Println("success!")
}
替换下面:
参考:
https://docs.gitlab.cn/jh/user/profile/personal_access_tokens.html