[Go Modules] Incorrect go-import meta tag for <SUBGROUP>/<REPO_PATH> prevents installation over SSH

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

When attempting to install the Go module via:

go install <SUBGROUP>/<REPO_PATH>@<VERSION>

Go retrieves an incorrect go-import meta tag from:

https://<HOST>/<GROUP>/<SUBGROUP>/<REPO_PATH>?go-get=1

The returned meta tag points to the parent repository in the main group instead of the actual repository:

<meta name="go-import" content="<HOST>/<GROUP> git https://<HOST>/<GROUP>.git">

Problem Details

  1. The repository <REPO_PATH> is located inside a subgroup (<SUBGROUP>) of the main group (<GROUP>).
  2. GitLab’s default go-import meta tag does not correctly handle nested repositories in subgroups. Go ends up trying to fetch the code from the main group repository (<GROUP>.git) instead of <SUBGROUP>/<REPO_PATH>.git.
  3. The module cannot be installed over SSH either, because Go still points to the wrong repository.
  4. The version tag <VERSION> exists in the actual repository, but Go cannot find it due to the incorrect meta tag.
  5. The goal is to allow Go to fetch modules from the subgroup repository directly, without restructuring everything to move the repo to the main group.

Steps to Reproduce

  1. Run:

    GOPROXY=direct go install <SUBGROUP>/<REPO_PATH>@<VERSION>
  2. Observe Go attempts to fetch from the wrong repository (<GROUP>.git) instead of <SUBGROUP>/<REPO_PATH>.git.


Expected Behavior

  • Go should fetch the module from the actual repository <HOST>/<GROUP>/<SUBGROUP>/<REPO_PATH>.git
  • Both HTTPS and SSH installation should succeed if the user has access rights.

Suggested Solutions

  1. Correct the go-import meta tag so it points to the actual repository:

    <meta name="go-import" content="<HOST>/<GROUP>/<SUBGROUP>/<REPO_PATH> git https://<HOST>/<GROUP>/<SUBGROUP>/<REPO_PATH>.git">
  2. Alternatively, allow fetching modules from the subgroup repository without having to restructure everything into the main group.

Edited by 🤖 GitLab Bot 🤖