1
2
3
4
5
6
7 package goroot
8
9 import (
10 "os"
11 "path/filepath"
12 "strings"
13 )
14
15
16
17 func IsStandardPackage(goroot, compiler, path string) bool {
18 switch compiler {
19 case "gc":
20 dir := filepath.Join(goroot, "src", path)
21 dirents, err := os.ReadDir(dir)
22 if err != nil {
23 return false
24 }
25 for _, dirent := range dirents {
26 if strings.HasSuffix(dirent.Name(), ".go") {
27 return true
28 }
29 }
30 return false
31 case "gccgo":
32 return stdpkg[path]
33 default:
34 panic("unknown compiler " + compiler)
35 }
36 }
37
View as plain text