Should setting GOVCS to git for a private repo prevent the VCS resolution request?

Hi team,

My use case - I’d like to import a package from a private git repository. The repository is a self hosted gitlab instance, and to make things tricky, the web server is configured to use mutual TLS, and the SSH port is non-default.

I’ve done three things to get this to work:

  1. Make “go get” use git.
  2. Tell git to use SSH instead of HTTPS for my private url in ~/.gitconfig.
  3. Tell SSH to use to use the non-default port in ~/.ssh/config.

Once I’ve done this the following works:

GOPRIVATE=git.example.com go get -u -x git.example.com/foo/bar.git

(Stangely this hangs without setting GOPRIVATE - not sure why - something for another day)

The command solves 1), by adding “.git” to the module name.

Apparently I can also solve 1) by adding a meta tag to git.example.com, or just example.com which tells “go get” to use git. (It’s a bit weird for git.example.com due to the mutual TLS, but I guess I could add the meta tag to the “Bad Request” error page that you get without a client cert.) But let’s assume I can’t update the meta tags for either website for now.

From the docs I’d thought that it would also be possible to force “go get” to use git via setting the GOVCS env var to git. But this appears not to be the case.

Example of the current behaviour:

GOVCS=git.example.com:git GOPRIVATE=git.example.com go get -u -x git.example.com/foo/bar

The following command prints:

$ GOVCS=git.example.com:git GOPRIVATE=git.example.com go get -u -x git.example.com/example/foo
# get https://git.example.com/?go-get=1
# get https://git.example.com/example?go-get=1
# get https://git.example.com/example/foo?go-get=1
# get https://git.example.com/example/foo?go-get=1: 400 Bad Request (0.363s)
# get https://git.example.com/example?go-get=1: 400 Bad Request (0.363s)
# get https://git.example.com/?go-get=1: 400 Bad Request (0.363s)
# get https://git.example.com/?go-get=1
# get https://git.example.com/example/foo?go-get=1
# get https://git.example.com/example?go-get=1
# get https://git.example.com/example?go-get=1: 400 Bad Request (0.045s)
# get https://git.example.com/example/foo?go-get=1: 400 Bad Request (0.045s)
# get https://git.example.com/?go-get=1: 400 Bad Request (0.045s)
go get: unrecognized import path "git.example.com/example/foo": reading https://git.example.com/example/foo?go-get=1: 400 Bad Request

Would it make sense for me to file a feature request to allow the GOVCS env var to configure which VCS system to use for “go get”, and skip the VCS resolution requests?

Or is there already another way to do this?

Has this been discussed before?

Very new to Go, and I’d appreciate any advice.

Cheers,
Greg.