Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"go get" private github repository using two factor authentication

Tags:

go

go-modules

Our private organization GitHub account is authenticated via

  1. Two-factor authentication

  2. Personal access token

When I am trying to get go module via go get which is in the private organization Github

unrecognized import path "<repo>/api?go-get=1: no go-import meta tags ()

I found a similar thread but the solution didn't work for me

What's the proper way to "go get" a private repository?

Also, I found https://medium.com/@dayakar88/a-guide-to-solve-no-go-import-meta-tags-for-private-repositories-with-go-modules-6b9237f9c9f seems proper solution for my case but I can't understand the solution

like image 626
shellakkshellu Avatar asked Oct 15 '25 14:10

shellakkshellu


1 Answers

I've accomplished this by setting up the go for non-public modules passing the Github account as the value.

And by configuring the proxy to fetch it directly.

Optionally, you can force the go get command to use the Github personal access token in the URL ou the SSH (if you let the http:// will fail, since it'll not have access to the repository)

EXPORT GOPRIVATE=github.com/YOURACCOUNT && \
EXPORT GOPROXY=direct && \
git config --global url."https://${GITHUB_TOKEN}@github.com/".insteadOf https://github.com/
like image 59
twsouza Avatar answered Oct 17 '25 10:10

twsouza



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!