shamon shamsudeen
shamon shamsudeen

Reputation: 5848

"go get" private github repository using two factor authentication

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

Upvotes: 4

Views: 3349

Answers (1)

twsouza
twsouza

Reputation: 103

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/

Upvotes: 4

Related Questions