]> Cypherpunks repositories - gostls13.git/commitdiff
imports: make ScanDir ignore go files start with dot
authorKeyuan <keyuanli123@gmail.com>
Wed, 21 Oct 2020 02:47:29 +0000 (19:47 -0700)
committerBryan C. Mills <bcmills@google.com>
Thu, 22 Oct 2020 13:39:31 +0000 (13:39 +0000)
Adding "." Prefix Check for go files.

Fixes #42047
Change-Id: Ifc42bf562f52fdd304f9828b06fc57888fcd8049
Reviewed-on: https://go-review.googlesource.com/c/go/+/264078
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Jay Conrod <jayconrod@google.com>
Trust: Bryan C. Mills <bcmills@google.com>

src/cmd/go/internal/imports/scan.go
src/cmd/go/internal/imports/testdata/android/.h.go [new file with mode: 0644]
src/cmd/go/internal/imports/testdata/illumos/.h.go [new file with mode: 0644]
src/cmd/go/testdata/script/import_ignore.txt [new file with mode: 0644]

index d45393f36c5a697210f6bbd87bdd12a82e00bd6b..d7e674b129e62314c88c5628ea38b4b258ef1463 100644 (file)
@@ -34,7 +34,7 @@ func ScanDir(dir string, tags map[string]bool) ([]string, []string, error) {
                        }
                }
 
-               if info.Mode().IsRegular() && !strings.HasPrefix(name, "_") && strings.HasSuffix(name, ".go") && MatchFile(name, tags) {
+               if info.Mode().IsRegular() && !strings.HasPrefix(name, "_") && !strings.HasPrefix(name, ".") && strings.HasSuffix(name, ".go") && MatchFile(name, tags) {
                        files = append(files, filepath.Join(dir, name))
                }
        }
diff --git a/src/cmd/go/internal/imports/testdata/android/.h.go b/src/cmd/go/internal/imports/testdata/android/.h.go
new file mode 100644 (file)
index 0000000..53c529e
--- /dev/null
@@ -0,0 +1,3 @@
+package android
+
+import _ "h"
diff --git a/src/cmd/go/internal/imports/testdata/illumos/.h.go b/src/cmd/go/internal/imports/testdata/illumos/.h.go
new file mode 100644 (file)
index 0000000..53c529e
--- /dev/null
@@ -0,0 +1,3 @@
+package android
+
+import _ "h"
diff --git a/src/cmd/go/testdata/script/import_ignore.txt b/src/cmd/go/testdata/script/import_ignore.txt
new file mode 100644 (file)
index 0000000..83a39a0
--- /dev/null
@@ -0,0 +1,11 @@
+cp go.mod go.mod.orig
+go mod tidy
+cmp go.mod go.mod.orig
+
+-- go.mod --
+module m.test
+
+go 1.16
+-- .ignore.go --
+package p
+import _ "golang.org/x/mod/modfile"
\ No newline at end of file