aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKeyuan <keyuanli123@gmail.com>2020-10-20 19:47:29 -0700
committerBryan C. Mills <bcmills@google.com>2020-10-22 13:39:31 +0000
commited2010e676042b387d72daaa4c39b54c4c57c031 (patch)
tree3c5937b6bdd72ebd2f9d5a1e604bdffa6cc73e13 /src
parent9c28a50fd18b2e69c43dec9b871e96bab6ec4ede (diff)
downloadgo-ed2010e676042b387d72daaa4c39b54c4c57c031.tar.xz
imports: make ScanDir ignore go files start with dot
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>
Diffstat (limited to 'src')
-rw-r--r--src/cmd/go/internal/imports/scan.go2
-rw-r--r--src/cmd/go/internal/imports/testdata/android/.h.go3
-rw-r--r--src/cmd/go/internal/imports/testdata/illumos/.h.go3
-rw-r--r--src/cmd/go/testdata/script/import_ignore.txt11
4 files changed, 18 insertions, 1 deletions
diff --git a/src/cmd/go/internal/imports/scan.go b/src/cmd/go/internal/imports/scan.go
index d45393f36c..d7e674b129 100644
--- a/src/cmd/go/internal/imports/scan.go
+++ b/src/cmd/go/internal/imports/scan.go
@@ -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
index 0000000000..53c529e777
--- /dev/null
+++ b/src/cmd/go/internal/imports/testdata/android/.h.go
@@ -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
index 0000000000..53c529e777
--- /dev/null
+++ b/src/cmd/go/internal/imports/testdata/illumos/.h.go
@@ -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
index 0000000000..83a39a0be3
--- /dev/null
+++ b/src/cmd/go/testdata/script/import_ignore.txt
@@ -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