in getdeps/gopkg.go [24:65]
func (pkg *Gopkg) Get(projectDir string, urlOverrides *URLOverrides, hashMode HashMode) error {
dir, err := os.Getwd()
if err != nil {
return err
}
goDir := path.Join(dir, "gopath/src")
if err = os.MkdirAll(goDir, os.ModePerm); err != nil {
return err
}
url, err := url.Parse(pkg.Pkg)
if err != nil {
return err
}
dirs := strings.Split(url.Host+url.Path, "/")
for i := 0; i < len(dirs); i++ {
goDir = path.Join(goDir, dirs[i])
if err = os.MkdirAll(goDir, os.ModePerm); err != nil {
return err
}
}
repo := strings.Replace(pkg.Pkg, "golang.org/x", "go.googlesource.com", 1)
branch := defaultBranch
if pkg.Branch != nil && *pkg.Branch != "" {
branch = *pkg.Branch
} else {
pkg.Branch = &branch
}
hash := ""
if pkg.Hash != nil {
hash = *pkg.Hash
}
currentHash, err := gitClone(pkg.Label, repo, goDir, branch, hashMode, hash, urlOverrides)
if err != nil {
return err
}
pkg.Hash = ¤tHash
return nil
}