How to go mod download a private remote package in Github (error: “could not read Username”)

I’m trying to access a Go private remote package on my firm’s Github inside a CircleCI’s job. I’ve managed to get it in the test job, with:

git config --global url."https://{user}:${token}@github.com/".insteadOf "https://github.com/"

But somehow, this command doesn’t work in the build job. I have this error at the Build app Docker image step, when “RUN go mod download” is launched :

fatal: could not read Username for 'https://github.com': terminal prompts disabled

I’ve read a lot of issues about it (this Medium sums up soluces I’ve tried), I’ve tried to change export git_terminal_prompt=1 but nothing works.

Any idea ? Many thanks !

You’d need to configure that NPM registry and install it as dependency.

    - checkout
    - run:
        name: Login to private GitHub registry
        command: npm config set //npm.pkg.github.com/:_authToken $GITHUB_TOKEN
    - run: 
        name: Installing modules
        command: yarn install
...

To setup the GitHub token, please refer to the documentation https://help.github.com/en/articles/creating-a-personal-access-token-for-the-command-line

@FradiFrad Did you ever figure this out? I am trying with

echo "machine github.com login silenceisgolden password ${GITHUB_ACCESS_TOKEN}" > $HOME/.netrc 

but still getting Not Found errors when running go mod download.

Did you ever find a solution?