-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathout.go
More file actions
47 lines (40 loc) · 825 Bytes
/
out.go
File metadata and controls
47 lines (40 loc) · 825 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package dragon
import (
"fmt"
"io"
"os"
"path/filepath"
)
func out(libChan chan lib, w io.Writer) error {
stdlib := map[string]map[string]bool{
"unsafe": map[string]bool{
"Alignof": true,
"ArbitraryType": true,
"Offsetof": true,
"Pointer": true,
"Sizeof": true,
},
}
for lib := range libChan {
objMap, ok := stdlib[lib.path]
if !ok {
objMap = make(map[string]bool)
}
objMap[lib.object] = true
stdlib[lib.path] = objMap
}
_, err := fmt.Fprintf(w, `// AUTO-GENERATED BY dragon-imports
package imports
var stdlib = %#v
`, stdlib)
return err
}
func outPath() string {
for _, src := range srcDirs() {
outPath := filepath.Join(src, "golang.org/x/tools/internal/imports")
if _, err := os.Stat(outPath); err == nil {
return outPath
}
}
return ""
}