forked from cloudflare/circl
/
all_imports.go
49 lines (43 loc) · 996 Bytes
/
all_imports.go
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
48
49
//go:build ignore
// +build ignore
// Generates a Go program with all the public imports of CIRCL. It is used to
// test compilation using static (buildmode=default) and dynamic linking
// (buildmode=plugin).
package main
import (
"flag"
"fmt"
"io/fs"
"os"
"strings"
)
func main() {
outputFileName := flag.String("out", "circl.go", "name of the output file.")
flag.Parse()
f, err := os.Create(*outputFileName)
if err != nil {
panic(err)
}
defer f.Close()
skipDirs := []string{".", "testdata", "internal", "templates"}
circl := "github.com/cloudflare/circl/"
fmt.Fprintln(f, "package main")
err = fs.WalkDir(os.DirFS("."), ".", func(path string, d fs.DirEntry, err error) error {
if err != nil {
panic(err)
}
if d.IsDir() {
for _, sd := range skipDirs {
if strings.Contains(path, sd) {
return nil
}
}
fmt.Fprintf(f, "import _ \"%v%v\"\n", circl, path)
}
return nil
})
if err != nil {
panic(err)
}
fmt.Fprintln(f, "func main() {}")
}