プライベートリポジトリを「取得」する適切な方法は何ですか? 質問する

プライベートリポジトリを「取得」する適切な方法は何ですか? 質問する

$ go get何度も Google で検索した後、プライベート リポジトリで作業する方法を探しています。

最初の試み:

$ go get -v gitlab.com/secmask/awserver-go
Fetching https://gitlab.com/secmask/awserver-go?go-get=1
https fetch failed.
Fetching http://gitlab.com/secmask/awserver-go?go-get=1
Parsing meta tags from http://gitlab.com/secmask/awserver-go?go-get=1 (status code 200)
import "gitlab.com/secmask/awserver-go": parse http://gitlab.com/secmask/awserver-go?go-get=1: no go-import meta tags
package gitlab.com/secmask/awserver-go: unrecognized import path "gitlab.com/secmask/awserver-go

はい、ログイン情報の提供方法がわからなかったため、メタタグが表示されませんでした。

2回目の試み:

フォローするhttps://gist.github.com/shurcooL/6927554 より.gitconfig に config を追加します。

[url "ssh://[email protected]/"]
    insteadOf = https://gitlab.com/
$ go get -v gitlab.com/secmask/awserver-go --> not work
$ go get -v gitlab.com/secmask/awserver-go.git --> work but I got src/gitlab.com/secmask/awserer-go.git

はい、動作しますが、.gitプロジェクト名に拡張子が付いているため、元の名前に戻すことはできますが、毎回それを実行するのは$ go getあまり良くありません。他に方法はありますか?

ベストアンサー1

設定する必要があるものが 1 つあります。この例は GitHub に基づいていますが、これによってプロセスが変わることはありません。

$ git config --global [email protected]:.insteadOf https://github.com/
$ cat ~/.gitconfig
[url "[email protected]:"]
    insteadOf = https://github.com/
$ go get github.com/private/repo

Go モジュールを動作させるには (Go 1.11 以降)、GOPRIVATEパブリック サーバーを使用してコードを取得することを避けるために、変数を設定する必要もあります。

export GOPRIVATE=github.com/private/repo

おすすめ記事