douzhongjian0752 2018-11-28 05:01
浏览 65

如何使用go模块在GAE SE Go 1.11上导入私有存储库?

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/libpackage@v0.0.0-20181127123728-008fddddc190: 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!

  • 写回答

1条回答 默认 最新

  • dsxgby126001 2018-11-28 14:21
    关注

    Send github credentials to go get:

    git config credential.helper '!f() { sleep 1; echo "username=${GIT_USER}
    password=${GIT_PASSWORD}"; }; f'
    
    export GIT_USER=github_user
    export GIT_PASSWORD=github_password_or_token
    
    go get github.com/foo/libpackage
    
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度