Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How do I run go get on a private repo

ae-ou
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 20, 2020

I have two Go repos. One called foo - which is a package, and one called bar - which pulls in foo as a dependency.

Because of Go's archaic (a more appropriate description is probably against community guidelines) package management system, you have to specify the full domain name of a package that you pull in - so in my file `bitbucket.org/ae-ou/bar/cmd/main.go`, I have:

import "bitbucket.org/ae-ou/foo"

I initially had an issue where I was getting this output

go get bitbucket.org/ae-ou/foo: reading https://api.bitbucket.org/2.0/repositories/ae-ou/foo?fields=scm: 403 Forbidden
server response: Access denied. You must have write or admin access.

After looking up the output, several sites told me to run the following to force a connection via SSH:

git config --global url."git@bitbucket.org:".insteadOf "https://bitbucket.org/"

When I run `go get` to pull in the foo dependency, I now get a slightly different error:

go: downloading bitbucket.org/ae-ou/foo v0.1.0
go get bitbucket.org/ae-ou/foo: bitbucket.org/ae-ou/foo@v0.1.0: verifying module: bitbucket.org/ae-ou/foo@v0.1.0: reading https://sum.golang.org/lookup/bitbucket.org/ae-ou/foo@v0.1.0: 410 Gone
server response:
not found: bitbucket.org/ae-ou/foo@v0.1.0: reading https://api.bitbucket.org/2.0/repositories/ae-ou/foo?fields=scm: 403 Forbidden

It does seem to be finding and accessing my foo repo because the latest tag in it is 0.1.0, but the go get command is still failing due to a 403. I know for certain that I don't lack permissions on my SSH key, because I use that SSH key to push to/pull from Bitbucket all the time.

 

 

1 answer

1 accepted

7 votes
Answer accepted
ae-ou
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 20, 2020

Resolved. I had to restart the SSH agent in order for the .gitconfig change to take effect.

I was then faced with the following issue:

main.go:5:2: bitbucket.org/ae-ou/foo@v0.1.0: verifying module: bitbucket.org/ae-ou/foo@v0.1.0: reading https://sum.golang.org/lookup/bitbucket.org/ae-ou/foo@v0.1.0: 410 Gone

This is something that I'd addressed before - for those facing the same issue,  it's just a matter of exporting a variable to prevent Go from looking up the repo in sum.golang.org - as follows:

export GOPRIVATE="bitbucket.org/ae-ou"
Deleted user May 11, 2022

Hi, even with the GOPRIVATE setup correctly, I Still get 410 Gone error and go  checks the sum.golang.org still. Any ideas? I am running on Win.

thanks

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events