I coding a small application on golang and using go-git to clone git repository, but when I run it through a proxy, it can not to connect to internet. A piece of code below:
url := os.Getenv("APP_DOWNLOAD_LOCATION")
username := "username"
password := "password"
if len(username) > 0 && len(password) > 0 {
cloneOptions.Auth = &http2.BasicAuth{
Username: username,
Password: password,
}
cloneOptions.
}
r, err := git.Clone(storer, fs, cloneOptions)
I searched but don't have any guide for configure go-git to clone through a proxy. Has anyone encountered this case yet? Thanks so much.
auth/basic/username_password/main.go
does not seem to be for proxy authentication though.
For proxy, you would need to set a custom client (as in _examples/custom_http/main.go
, with the http.Transport
set with your credentials.