Jetbrains Space + go get
Given:
- You’re using
Jetbrains Space1. - You write code in
Go. - You need to create a shared library and pull it in as a module across your internal projects.
Constraints:
Spacedoesn’t let you create nested subgroups. To some extent, that’s a good thing.- Each library has to live in its own repository.
First, let’s configure git. Add the following directive to ~/.gitconfig:
[url "git@git.jetbrains.space/<org-name>"]
insteadOf = https://<org-name>.jetbrains.space/
Here <org-name> is the part of the domain name that belongs to your organization.
Create or reuse a project to host the library repositories. In the examples below I’ll assume it’s called lib —
feel free to use any name you like.
Inside the lib project, create the repository for your library. Initialize the Go module like this:
go mod init <org-name>.jetbrains.space/lib/<lib-name>
Substitute the library/repository name for <lib-name>. Drop your library’s source code into the repository and push
it.
To add your new internal library to a project, run the following:
export GONOSUMDB=<org-name>.jetbrains.space
go get <org-name>.jetbrains.space/lib/<lib-name>
With this in place, Go won’t go off to check your library against GOSUMDB, and it’ll be pulled in as a dependency.
What to do with the GONOSUMDB variable is up to you:
- you can persist it via
go env -w ...; - export it in your shell’s
rcfile; - set it as a per-process environment variable each time, by hand.