Skip to content

Commit

Permalink
Merge pull request #1566 from visualfc/install
Browse files Browse the repository at this point in the history
gop install: contains @ version use remote pkgpath
  • Loading branch information
xushiwei committed Dec 6, 2023
2 parents dc3bc85 + eaf54d8 commit 6c081ba
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions gengo.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,23 +205,30 @@ func GenGoPkgPath(workDir, pkgPath string, conf *Config, allowExtern bool) (loca
return GenGoPkgPathEx(workDir, pkgPath, conf, allowExtern, 0)
}

func remotePkgPath(pkgPath string, conf *Config, recursively bool, flags GenFlags) (localDir string, _recursively bool, err error) {
remotePkgPathDo(pkgPath, func(dir, _ string) {
os.Chmod(dir, modWritable)
defer os.Chmod(dir, modReadonly)
localDir = dir
_recursively = recursively
err = genGoDir(dir, conf, false, recursively, flags)
}, func(e error) {
err = e
})
return
}

func GenGoPkgPathEx(workDir, pkgPath string, conf *Config, allowExtern bool, flags GenFlags) (localDir string, recursively bool, err error) {
recursively = strings.HasSuffix(pkgPath, "/...")
if recursively {
pkgPath = pkgPath[:len(pkgPath)-4]
} else if allowExtern && strings.Contains(pkgPath, "@") {
return remotePkgPath(pkgPath, conf, false, flags)
}

mod, err := gopmod.Load(workDir, 0)
if NotFound(err) && allowExtern {
remotePkgPathDo(pkgPath, func(dir, _ string) {
os.Chmod(dir, modWritable)
defer os.Chmod(dir, modReadonly)
localDir = dir
err = genGoDir(dir, conf, false, recursively, flags)
}, func(e error) {
err = e
})
return
return remotePkgPath(pkgPath, conf, recursively, flags)
} else if err != nil {
return
}
Expand Down

0 comments on commit 6c081ba

Please sign in to comment.