The most common errors occur when deploying a Go project from GitLab repositories.

"golang remote: The project you were looking for could not be found or you don't have permission to view it."

OR

"fatal could not read username for 'https //gitlab.com' terminal prompts disabled"

The main reasons behind that are related to authentication and permissions. To solve that, we need to create the following files and fill them with the suitable credentials with the exact syntax:

1- .gitconfig

2- .git-credentials

3- .netrc

And, for sure, you need to place these files under the home directory of the user being used. Ex. moving the files to home directory:

mv .gitconfig ~/ mv .git-credentials ~/ mv .netrc ~/ chmod 600 ~/.git-credentials ~/.netrc

Now, lets start with the content of these files with the exact syntax and make sure editing them to your credentials:

1- .gitconfig

[credential] helper = store [user] email = username@domain.com name = Your name [http] # Only needed if your GitLab uses a self-signed certificate sslverify = false

2- .git-credentials

https://username:TheGeneratedTokenFromGitlab@domainForGitlab.com

3- .netrc

machine is the hostname of your GitLab server (e.g. gitlab.com), not the local machine:

machine domainForGitlab.com login username password TheGeneratedTokenFromGitlab

Finally, tell Go that modules on your GitLab are private so it fetches them directly instead of through the public proxy:

go env -w GOPRIVATE=domainForGitlab.com