ghqとは
git(やhg他)のレポジトリをいい感じにチェックアウトし、一覧したりできるようにするツールです。
install
brew tap motemen/ghq
brew install ghq
go get
は非推奨とのこと
必要な設定
ghq.root
ghqがリポジトリをインストールするチェックアウト先
デフォルトは ~/.ghq
ghq.<url>.vcs
特定のホスト以下はどのVCSを使うか決め打ちできる。GHEなどで必要
$ git config --list | grep ghq
ghq.https://ghe.your.host.vcs=git
使う
ghq get https://github.com/haconiwa/haconiwa
すると
(デフォルトで)
~/.ghq/github.com/haconiwa/haconiwa
と言うディレクトリを掘って、チェックアウトしてくれる
何をチェックアウトしたかの一覧
$ ghq list | head
bitbucket.org/ged/ruby-pg
bitbucket.org/kardianos/osext
bogomips.org/unicorn
code.google.com/p/freetype-go
code.google.com/p/go-uuid
code.google.com/p/go.crypto
code.google.com/p/go.net
code.google.com/p/go.text
code.google.com/p/go.tools
code.google.com/p/goauth2
フルパスなら ghq list -p
(pecoと組み合わせると...??)
なぜ必要か
ディレクトリ規約を考えるのは面倒
「決めの問題」は、いい感じのスタンダードに乗るのが一番
c.f. Ruby on Rails
「規約に沿ったファイルシステムを作る」だけで、例えば一覧機能もあっさり利用できたりするわけで。
go言語のライブラリの規約にも沿っている
$GOPATH/src
を $GHQ_ROOT
に向けるとそのままソース置き場になる
こんな感じです
$ ls -la ~/.go
total 4
drwxr-xr-x 6 udzura staff 204 8 20 2014 ./
drwxr-xr-x+ 150 udzura staff 5100 10 5 10:55 ../
drwxr-xr-x 119 udzura staff 4046 6 20 11:56 bin/
drwxr-xr-x 5 udzura staff 170 5 26 2015 pkg/
lrwxr-xr-x 1 udzura staff 18 8 20 2014 src -> /Users/udzura/.ghq/
drwxr-xr-x 4 udzura staff 136 7 14 2014 src.orig/