aboutsummaryrefslogtreecommitdiff
path: root/src/embed
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2021-10-28 13:22:07 -0400
committerRuss Cox <rsc@golang.org>2021-11-09 18:03:59 +0000
commit36dbf7f7e63f3738795bb04593c3c011e987d1f3 (patch)
treed07b075f36248f979a003f36c18a18e5668cf558 /src/embed
parent15a54d627ca7a0bdf45a3d1862b35a892024cacc (diff)
downloadgo-36dbf7f7e63f3738795bb04593c3c011e987d1f3.tar.gz
go-36dbf7f7e63f3738795bb04593c3c011e987d1f3.zip
cmd/go: add //go:embed all:pattern
When //go:embed d matches directory d, it embeds the directory tree rooted at d, but it excludes files beginning with . and _, as well as files having problematic names that will not be packaged into modules (names such as .git and com1). After long discussions on #42328 and #43854, we decided to keep the behavior of excluding . and _ files by default, but to allow the pattern prefix 'all:' to override this default. This CL implements that change. Note that paths like .git and com1 are still excluded, as they must be, since they will never be packed into a module. Fixes #43854. Change-Id: I4f3731e14ecffd4b691fda3a0890b460027fe209 Reviewed-on: https://go-review.googlesource.com/c/go/+/359413 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Jonathan Amsterdam <jba@google.com> Reviewed-by: Bryan C. Mills <bcmills@google.com>
Diffstat (limited to 'src/embed')
-rw-r--r--src/embed/embed.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/embed/embed.go b/src/embed/embed.go
index f87cc5b963..24c3a89e9b 100644
--- a/src/embed/embed.go
+++ b/src/embed/embed.go
@@ -80,6 +80,11 @@
// var content embed.FS
//
// The difference is that ‘image/*’ embeds ‘image/.tempfile’ while ‘image’ does not.
+// Neither embeds ‘image/dir/.tempfile’.
+//
+// If a pattern begins with the prefix ‘all:’, then the rule for walking directories is changed
+// to include those files beginning with ‘.’ or ‘_’. For example, ‘all:image’ embeds
+// both ‘image/.tempfile’ and ‘image/dir/.tempfile’.
//
// The //go:embed directive can be used with both exported and unexported variables,
// depending on whether the package wants to make the data available to other packages.