'How to install a go library from github without public key?

I want to install the gqrcode project and get from that project the following installation instructions:

go get -u github.com/KangSpace/gqrcode

When performing this, I first got:

...

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

...

After performing

git config --global --add url."[email protected]:".insteadOf "https://github.com/"

I get:

[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
package github.com/KangSpace/gqrcode: exit status 1

In other languages like python I can clone the library first (git clone ....) and afterwards install it.

How can I perform something similar in go?



Solution 1:[1]

If it stills uses an HTTPS URL, despite your global git config url."[email protected]:".insteadOf directive, you might need and try using a PAT (personal access token) instead.

As in this example, try

git config --global url."https://${GITHUB_TOKEN}:[email protected]/".insteadOf "https://github.com/"

(Assuming you have access to the repository)

Howver, considering https://github.com/gqrcode itself is 404, the github.com/gqrcode/xxx imports declared in github.com/KangSpace/gqrcode might need to be updated first.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 VonC