"go get" a private bitbucket repo

4,137 views
Skip to first unread message

Chandra Sekar S

unread,
Jul 9, 2012, 11:31:49 PM7/9/12
to golan...@googlegroups.com
When I try to "go get" a private bitbucket repo, I get a "401 UNAUTHORIZED".  Is there anyway to pass the basic auth detail for go get to pass on to git?

Tarmigan

unread,
Jul 10, 2012, 12:18:01 AM7/10/12
to Chandra Sekar S, golan...@googlegroups.com
On Mon, Jul 9, 2012 at 8:31 PM, Chandra Sekar S <chand...@gmail.com> wrote:
> When I try to "go get" a private bitbucket repo, I get a "401 UNAUTHORIZED".
> Is there anyway to pass the basic auth detail for go get to pass on to git?

What I have done is manual mkdir of the appropriate directory and then
manual done a git clone. Once the local git repo is initialized, "go
get" etc can fetch updates if you teach git about your credentials
either via ssh keys or .netrc for https.

Thanks,
Tarmigan

Chandru

unread,
Jul 10, 2012, 1:22:47 AM7/10/12
to golan...@googlegroups.com
That sounds unnecessarily complicated especially when you have multiple libraries imported and you want to set up a new development machine.

Why doesn't go get prompt for authentication as it uses git underneath anyway or at least provide an option to pass credentials?

--
Chandra Sekar.S

Chandru

unread,
Jul 10, 2012, 5:45:15 AM7/10/12
to golan...@googlegroups.com
I want to setup a bunch of go get-able libraries internal to the organization. So far I've managed to set up git over HTTPS with nginx and that works fine.

However, I want to add authentication to the libraries. If there is an alternative method I can use to set up authentication without losing go get-ability, that'll work too.

--
Chandra Sekar.S

André Moraes

unread,
Jul 10, 2012, 7:30:49 AM7/10/12
to Chandru, golan...@googlegroups.com
"go get" is a wrapper to invoke the VCS of your repository, so,
if you "go get github.com/someuser/somepath" go get will call

git clone https://github.com/someuser/somepath
$GOPATH/src/github.com/someuser/somepath

This logic is in this file: http://golang.org/src/cmd/go/vcs.go

go get -x <<your import path>>

will print all the commands invoked by go-get.

--
André Moraes
http://amoraes.info

Chandru

unread,
Jul 10, 2012, 8:52:01 AM7/10/12
to golan...@googlegroups.com
Ah! Thanks for linking to the source code. It acts as a thin wrapper usually but for bitbucket, it makes an API call to determine the SCM type and this API call doesn't use .netrc. :(

--
Chandra Sekar.S
Reply all
Reply to author
Forward
0 new messages