Repository: go
Issue: wiki: add page on using private repositories (e.g., on-prem GitLab, private github.com repos, etc.)
Labels: Documentation,help wanted,NeedsFix,modules

Consider adding a new wiki page on using Go with private repositories such as on-prem GitLab, on-prem GitHub, on-prem bitbucket, private github.com repos, etc.

This seems to be a fairly frequent source of confusion, and often it is when someone is new or somewhat new to Go, which means it both impacts early impressions of Go, as well as means someone at that point in time is less versed in Go overall (e.g., it is more challenging to work through how to set up something like an on-prem GitLab instance if someone is asking "what is an import path?" at more or less the same time).

It also comes up in the context of modules (because of a different error with modules, or because someone initially assumes they are seeing a module-specific issue, etc.). I would wager that at this point in time, a private repo problem that is reported in the context of modules  the majority of the time ends up not actually being a module-specific issue (at least as of 1.11), but there are also module-specific aspects such as how to have an internal corporate mirror via the `replace`directive, etc.

Part of the current complexity comes from the fact that it is a moving target with products like GitLab and GitHub Enterprise improving over time (or in some cases, having new bugs), which also means currently people can end up talking past each other in terms of a specific solution if they are on different versions. A similar piece of current complexity is that sometimes a solution described for GitHub Enterprise also works for GitLab and other solutions, but sometimes that is not the case.

Having a wiki page could help on all of those fronts, including helping to draft off of community experience. It might also cut down on people reinventing solutions from scratch. I personally would not expect this type of material to be in the core Go documentation, nor would I expect the core Go team to be experts in something like on-prem GitLab.

I am not sure of the best title, but perhaps "Private Repositories", or "Working with Private Repositories"?

### Some current material

* https://golang.org/doc/faq#git_https
* https://golang.org/cmd/go/#hdr-Remote_import_paths
* https://github.com/golang/go/issues/26134 "cmd/go: github private repos require special configuration"
* https://github.com/golang/go/issues/27254#issuecomment-419340291 "cmd/go: custom import path private repos require special configuration"
* ["gitlab not support go-get with sub-groups"](https://gitlab.com/gitlab-org/gitlab-ce/issues/37832#note_52388964 )
* ["Jan 22 2019 GitLab release notes: Support for private Go packages in subgroups"](https://about.gitlab.com/2019/01/22/gitlab-11-7-released/#support-for-private-go-packages-in-subgroups)

### Some older items
* https://github.com/golang/go/issues/24076#issuecomment-371371558
* https://github.com/golang/go/issues/24076#issuecomment-424330150
* https://github.com/golang/go/issues/17898#issuecomment-376631102
* #26894 "cmd/go: using git over ssh fails to load modules requirements"
* #28422 "cmd/go: insteadOf broken with MacOS git 2.19.1 and go version 1.11.1?"
* #28653 "cmd/go: mod falls to download dependencies due to git not using ssh""

### Some sample community commentary

The first four are taken from [here](https://www.reddit.com/r/golang/comments/9n2phh/go_1111_module_issue_with_gitlab/) (including as an example of people sharing different solutions that don't always work for the original reporter). The remainder are from various other discussions.

> I have to do this to get to private repos in Github using go get/dep/go mod:
> `git config --global url."git@github.com:".insteadOf "https://github.com/"`

> I have that in my .gitconfig - but it seems to ignore it. I also created a private repo token and added that as well. Both seemed to do nothing.

> We setup a nginx proxy with ssl cert in front of gitlab. Also I setup a url responder to respond back from "go get" requests. There is no need to have any edit to a ~/.git/config to have insteadOf etc

> I solved these problems for GitHub Enterprise. I put together a small go service modelled after https://github.com/niemeyer/gopkg for my team.

> https://help.github.com/enterprise/2.14/admin/guides/user-management/changing-authentication-methods/ says in `Git authentication`: “LDAP supports password-based Git authentication by default, but we recommend that you disable that method and force authentication via a personal access token or SSH key.”  Access with personal access tokens is described on https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/

> for gitlab:
`$ git config --global -l
url.gitlab@gitlab.int.company.com:.insteadof=https://gitlab.int.company.com/`

CC @bcmills @andybons @myitcv @mvdan @dmitris @leitzler