1. set env
1
2
3
4
5
6
7
8
9
10
11
|
# Set the git address of the private repository
go env -w GOPRIVATE="git@gitlab.xxx.cn"
# Allow setting unsecured access to a repository that can be requested to an http address after configuration
go env -w GOINSECURE="gitlab.xxx.cn"
# Set the request to this address without a proxy, i.e. GOPROXY
go env -w GONOPROXY="gitlab.xxx.cn"
# Set not to verify the signature of sum packages
go env -w GONOSUMDB="gitlab.xxx.cn"
|
If the library to be pulled is private and the secret key needs to be configured, the following command can be used.
1
2
3
4
|
# 1. Create a private repository secret key (this step is omitted, each platform is different)
# 2. Setting the secret key
$ git config --global http.extraheader "PRIVATE-TOKEN:<The secret key configured above>"
|
3. globally replace ssh request with http request
This step is to solve the problem of choosing http pull when it is not convenient to pull with ssh.
1
|
$ git config --global url."git@gitlab.xxx.cn".insteadOf "https://gitlab.xxx.cn"
|
This step can be done by directly omitting steps 2 and 3 and using the .netrc file (file path: ~/.netrc), as follows
1
|
machine gitlab.xxx.cn login <username> password <The secret key configured above>
|
Using this step also solves a problem with gitlab
where it fails to pull subgroups: Go get fails with the usage of subgroups. For example.
1
2
3
|
# The following pull command will report an error if you don't use step 4
# Because of the limitations of gitlab, you can only pull up to one level, i.e. gitlab.xxx.cn/a/b.git
$ go get -u gitlab.xxx.cn/a/b/c.git
|