junpayment
junpayment

Reputation: 137

How to import private repositories on GAE SE Go 1.11, with go modules?

I have a go library package repository on github as a private repository.

And I wrote a project like below that import the library package above.

package main

import "github.com/foo/libpackage"

func main() {
  :
}

This is a directory hierarchy.

path/to/project
  |- main.go
  |- go.mod
  `- go.sum

When deploying I got a error that cannot

go: github.com/foo/[email protected]: git fetch -f origin refs/heads/*:refs/heads/* refs/tags/*:refs/tags/* in /go/pkg/mod/cache/vcs/25a80f32a1edc8de002fe3d4532abdf933bba77505314d051e4b644faa9cabf6: exit status 128:
        fatal: could not read Username for 'https://github.com': terminal prompts disabled

It seems to get failed when go mod download. I think it cause GAE does not be permitted to access a private repository(This is convincing)

Next I tried to run go mod vendor to download repositories into the vendor directory.

path/to/project
  |- vendor/...
  |- main.go
  |- go.mod
  `- go.sum

But I got a same error.

help!

Upvotes: 2

Views: 455

Answers (1)

Everton
Everton

Reputation: 13825

Send github credentials to go get:

git config credential.helper '!f() { sleep 1; echo "username=${GIT_USER}\npassword=${GIT_PASSWORD}"; }; f'

export GIT_USER=github_user
export GIT_PASSWORD=github_password_or_token

go get github.com/foo/libpackage

Upvotes: 1

Related Questions