I'm working with a monorepo that is organized by language at the top level, so all Go modules are located in the go directory in the repository root. I want to set up a vanity import URL that points to the go directory rather than the repository root so that the go/ does not need to be included in the import path.
Current file structure:
/
go/
module1/
module2/
Desired import format:
import (
"go.example.com/module1"
"go.example.com/module2"
)
currently possible but not desired:
import (
"go.example.com/go/module1"
"go.example.com/go/module2"
)
According to the docs the format for the <meta> element at go.example.com should be of the form:
<meta name="go-import" content="import-prefix vcs repo-root">
So in this case I would have:
<meta name="go-import" content="go.example.com git github.com/example/repo">
This translates the path following the import-prefix to a path relative to the root directory of the repository, so that go.example.com/this/path looks for the this/path directory in the repo. I would like instead for the path to be relative to the go directory in the repo instead of the repo root.
Is there any way to inform go get that the paths following go.example.com should be relative to github.com/example/repo/go rather than just github.com/example/repo?