title: Using Go modules with private repositories via HTTP without SSL
body: <p>Is there a way to force the <code>go</code> command to use HTTP instead of HTTPS?</p>
  
  <p>I am trying to move a project to Go Modules, but this project includes a private <code>git</code> repository as a dependency.
  This <code>git</code> repository is hosted in a private LAN behind a firewall and I usually 
  clone it with something like <code>cd $GOPATH/git.ourdomain.net/foo/bar/ &amp;&amp; git clone http://my-user:my-password@git.ourdomain.net/foo/bar/reponame.git</code>.</p>
  
  <p>However now the commands <code>go mod</code>, <code>go get</code> and <code>go test</code> are trying to use HTTP with SSL (HTTPS).</p>
  
  <p>This setting is not helping:</p>
  
  <pre><code>git config \
    --global \
    url."http://my-user:my-password@git.ourdomain.net/foo/bar/reponame".insteadOf \
    "http://git.ourdomain.net"
  </code></pre>
  
  <p>(Check here for some context around <code>git</code> settings for private repositories: <a href="https://medium.com/cloud-native-the-gathering/go-modules-with-private-git-repositories-dfe795068db4" rel="nofollow noreferrer">https://medium.com/cloud-native-the-gathering/go-modules-with-private-git-repositories-dfe795068db4</a>)</p>
  
  <p>I've amended the file <code>go.mod</code> to include a reference to that private repository (using a pattern like <code>git.ourdomain.net/foo/bar/reponame@v0.0.0-&lt;YYYYMMDDHHmmSS&gt;-&lt;GIT_COMMIT_ID&gt;</code>), but when invoking <code>go test</code> with a file <code>go.mod</code> including that private repo, then I see:</p>
  
  <pre><code>go: git.ourdomain.net/foo/bar/reponame@v0.0.0-&lt;YYYYMMDDHHmmSS&gt;-&lt;GIT_COMMIT_ID&gt;: unrecognized import path "git.ourdomain.net/foo/bar/reponame" (https fetch: Get https://git.ourdomain.net/foo/bar/reponame?go-get=1: dial tcp &lt;PUBLIC_IP_ADDRESS&gt;:443: connect: connection refused)
  </code></pre>
  
  <p>I've also tried to revert <code>go.mod</code> to the original version (without that private repository) and tried to <code>go get</code> from the path where the file <code>go.mod</code> is stored, assuming that will somehow update the <code>go.mod</code> file via HTTP because of <code>-insecure</code> (check here <a href="https://golang.org/cmd/go/#hdr-Module_aware_go_get" rel="nofollow noreferrer">https://golang.org/cmd/go/#hdr-Module_aware_go_get</a>), like this:</p>
  
  <pre><code>GO111MODULE=on go get -insecure -u git.ourdomain.net/foo/bar/reponame
  </code></pre>
  
  <p>But this gave the error message: </p>
  
  <pre><code>fatal: remote error: Repository not found
  The requested repository does not exist, or you do not have permission to
  access it.
  </code></pre>
  
  <p>I know I should use SSL, but I've never had control on this <code>git</code> server to configure it the way it should be configured. So I just used <code>git clone</code> providing an HTTP URL (when behind the firewall) and it always worked.</p>