1
2
3
4
5
6
7 package toolchain
8
9 import (
10 "internal/syscall/unix"
11 "io/fs"
12 "os"
13 "path/filepath"
14 "syscall"
15
16 "cmd/go/internal/gover"
17 )
18
19
20 func pathDirs() []string {
21 return filepath.SplitList(os.Getenv("PATH"))
22 }
23
24
25
26
27 func pathVersion(dir string, de fs.DirEntry, info fs.FileInfo) (string, bool) {
28 v := gover.FromToolchain(de.Name())
29 if v == "" {
30 return "", false
31 }
32
33
34
35
36
37 err := unix.Eaccess(filepath.Join(dir, de.Name()), unix.X_OK)
38 if (err == syscall.ENOSYS || err == syscall.EPERM) && info.Mode()&0111 != 0 {
39 err = nil
40 }
41 if err != nil {
42 return "", false
43 }
44
45 return v, true
46 }
47
View as plain text