1
2
3
4
5 package httpcommon_test
6
7 import (
8 "bytes"
9 "os"
10 "path/filepath"
11 "strings"
12 "testing"
13 )
14
15
16
17 func TestNoNetHttp(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
27
28
29 data, err := os.ReadFile(file)
30 if err != nil {
31 t.Fatal(err)
32 }
33 if bytes.Contains(data, []byte(`"net/http"`)) {
34 t.Errorf(`%s: cannot import "net/http"`, file)
35 }
36 }
37 }
38
View as plain text