...
1
2
3
4
5 package bisect
6
7 import (
8 "os"
9 "path/filepath"
10 "strings"
11 "testing"
12 )
13
14
15
16
17 func TestNoImports(t *testing.T) {
18 files, err := filepath.Glob("*.go")
19 if err != nil {
20 t.Fatal(err)
21 }
22 for _, file := range files {
23 if strings.HasSuffix(file, "_test.go") {
24 continue
25 }
26 data, err := os.ReadFile(file)
27 if err != nil {
28 t.Error(err)
29 continue
30 }
31 if strings.Contains(string(data), "\nimport") {
32 t.Errorf("%s contains imports; package bisect must not import other packages", file)
33 }
34 }
35 }
36
View as plain text