mirror of https://github.com/perkeep/perkeep.git
osutil: simplify GoPackagePath
Change-Id: If0af2e19c56d495ff46dc38a19b5148fa9f014fe
This commit is contained in:
parent
a82d394066
commit
78b4084f4c
|
@ -121,16 +121,6 @@ func FindCamliInclude(configFile string) (absPath string, err error) {
|
|||
return "", os.ErrNotExist
|
||||
}
|
||||
|
||||
func envVarSplitChar() string {
|
||||
switch runtime.GOOS {
|
||||
case "windows":
|
||||
return ";"
|
||||
case "plan9":
|
||||
panic("unsupported")
|
||||
}
|
||||
return ":"
|
||||
}
|
||||
|
||||
// GoPackagePath returns the path to the provided Go package's
|
||||
// source directory.
|
||||
// pkg may be a path prefix without any *.go files.
|
||||
|
@ -141,8 +131,8 @@ func GoPackagePath(pkg string) (path string, err error) {
|
|||
if gp == "" {
|
||||
return path, os.ErrNotExist
|
||||
}
|
||||
for _, p := range strings.Split(gp, envVarSplitChar()) {
|
||||
dir := filepath.Join(p, "src", pkg)
|
||||
for _, p := range filepath.SplitList(gp) {
|
||||
dir := filepath.Join(p, "src", filepath.FromSlash(pkg))
|
||||
fi, err := os.Stat(dir)
|
||||
if os.IsNotExist(err) {
|
||||
continue
|
||||
|
|
Loading…
Reference in New Issue