Skip to content

Instantly share code, notes, and snippets.

@vortexau
Last active December 27, 2023 03:09
Show Gist options
  • Save vortexau/bf3a00c7bd39e4e2900d81523e9a36b4 to your computer and use it in GitHub Desktop.
Save vortexau/bf3a00c7bd39e4e2900d81523e9a36b4 to your computer and use it in GitHub Desktop.
GCP / GCloud - Golang Private modules

Path from .git/config in origin tag something like https://source.developers.google.com/p/PROJECT/r/REPO

Set the env var like this:

go env -w GOPRIVATE=source.developers.google.com/p/<PROJECT>/r/\*

Then, go get will work, note .git extension required to work directly over git, this then uses the gcloud credential helper configured in the .git/config inside this repo,

go get source.developers.google.com/p/<PROJECT>/r/<MODULE>.git

Init the package with a command like:

go mod init source.developers.google.com/p/<PROJECT>/r/<REPO>.git

You will have to use .git in your import, too:

package main

import (
   // testing a private module here
    "source.developers.google.com/p/PROJECT/r/MODULE.git"
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment