Fixes #39841
Change-Id: Icbdc37d40e9c10179d6eb704d04482175b139f57
Reviewed-on: https://go-review.googlesource.com/c/go/+/240120
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
--- /dev/null
+env GO111MODULE=on
+[!symlink] skip
+
+symlink dir.go -> dir
+
+# Issue #39841: symlinks to directories should be ignored, not treated as source files.
+go list -f '{{range .GoFiles}}{{.}}{{"\n"}}{{end}}' .
+stdout 'p\.go$'
+! stdout 'dir\.go$'
+
+-- go.mod --
+module example.com
+go 1.15
+-- p.go --
+package p
+-- dir/README.txt --
+This file exists to ensure that dir is a directory.
if d.IsDir() {
continue
}
+ if (d.Mode() & os.ModeSymlink) != 0 {
+ if fi, err := os.Stat(filepath.Join(p.Dir, d.Name())); err == nil && fi.IsDir() {
+ // Symlinks to directories are not source files.
+ continue
+ }
+ }
name := d.Name()
ext := nameExt(name)