diff --git a/language/go/embed.go b/language/go/embed.go index f0c7548f5..69ac4766d 100644 --- a/language/go/embed.go +++ b/language/go/embed.go @@ -130,7 +130,7 @@ func newEmbedResolver(dir, rel string, validBuildFileNames []string, pkgRels map return filepath.SkipDir } for _, name := range validBuildFileNames { - if _, err := os.Stat(filepath.Join(p, name)); err == nil { + if bFileInfo, err := os.Stat(filepath.Join(p, name)); err == nil && !bFileInfo.IsDir() { // Directory already contains a build file. return filepath.SkipDir } diff --git a/language/go/testdata/embedsrcs/BUILD.want b/language/go/testdata/embedsrcs/BUILD.want index 7b48a51a1..46637a0c3 100644 --- a/language/go/testdata/embedsrcs/BUILD.want +++ b/language/go/testdata/embedsrcs/BUILD.want @@ -11,6 +11,7 @@ go_library( "m_static.txt", "n_/static.txt", "o_dir/_hidden.txt", + "p_dir/build.old/static.txt", ], importpath = "example.com/repo/embedsrcs", visibility = ["//visibility:public"], diff --git a/language/go/testdata/embedsrcs/embedsrcs.go b/language/go/testdata/embedsrcs/embedsrcs.go index 82ca45048..3e3eb2674 100644 --- a/language/go/testdata/embedsrcs/embedsrcs.go +++ b/language/go/testdata/embedsrcs/embedsrcs.go @@ -2,5 +2,5 @@ package embedsrcs import "embed" -//go:embed *m_* n_/* all:o* +//go:embed *m_* n_/* p_dir/* all:o* var fs embed.FS diff --git a/language/go/testdata/embedsrcs/p_dir/build.old/static.txt b/language/go/testdata/embedsrcs/p_dir/build.old/static.txt new file mode 100644 index 000000000..ab62a44c6 --- /dev/null +++ b/language/go/testdata/embedsrcs/p_dir/build.old/static.txt @@ -0,0 +1,2 @@ +# p_dir/build.old/static.txt should be embedded because while the subdirectory is named `build.old`, +# it is a directory and not an actual BUILD file. \ No newline at end of file