`git clone`到$ GOPATH而没有`go get`吗?

时间:2018-08-20 10:38:40

标签: bash git go sh developer-tools

对于格式不正确的Go软件包,这将不起作用:

go get -u

如何在没有clone的情况下go get,并且没有手动解析路径?

1 个答案:

答案 0 :(得分:-2)

出于我的目的编写了这个小shell函数,可能对您也很有用:

function glone()
{
  IFS='/' read -r _ _ host team repo <<< "$1";
  to_dir="${GOPATH:-$HOME/go}/src/$host/$team/$repo";
  if ! [ -d "$to_dir" ]; then
    mkdir -p "$to_dir";
    git clone "$1" "$to_dir";
  fi
  cd "$to_dir";
}

用法:

$ glone https://github.com/bradleyfalzon/gopherci
相关问题