Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

embed: embed directive does not add _ and . directories recursivley #45019

Closed
SimonBaeumer opened this issue Mar 15, 2021 · 2 comments
Closed
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@SimonBaeumer
Copy link

SimonBaeumer commented Mar 15, 2021

What version of Go are you using (go version)?

$ go version
go version go1.16.1 darwin/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/simon/Library/Caches/go-build"
GOENV="/Users/simon/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/simon/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/simon/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.16.1/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.16.1/libexec/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.16.1"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/simon/go/src/github.com/stackrox/rox/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/np/bn9w387j4ll0xly59mf3p6140000gn/T/go-build3155111729=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

  • Want to print all directories, including the ones prefixed with _ and .
  • Add // go:embed embed/* directive and store it into a embed.FS variable
  • Print all directories included in the embed.FS variable

Create the directory structure:

// To create the directory structure run:
// $ echo "embed/.invisible embed/_underscore embed/recursive/.invisible embed/recursive/_underscore embed/recursive/visible" | xargs mkdir -p
/*
embed
├── .invisible
├── _underscore
├── recursive
│   ├── .invisible
│   ├── _underscore
│   └── visible
└── visible
*/

//go:embed embed/*
var FS embed.FS
func main() {
	fs.WalkDir(FS, ".", func(p string, d fs.DirEntry, err error) error {
		fmt.Println(p)
		return nil
	})
}

Play golang: https://play.golang.org/p/ui10fGMnItQ

What did you expect to see?

Directories prefixed with . and _ under recursive should be displayed too.

.
embed
embed/.invisible
embed/_underscore
embed/recursive
embed/recursive/.invisible
embed/recursive/_underscore
embed/visible

What did you see instead?

.
embed
embed/.invisible
embed/_underscore
embed/recursive
embed/recursive/visible
embed/visible
@cherrymui
Copy link
Member

See also #42321 and #43854.

cc @rsc

Feel free to close as a dup.

It looks a bit weird to me that the top-level . and _ files are included.

@cherrymui cherrymui changed the title embed directive does not add _ and . directories recursivley embed: embed directive does not add _ and . directories recursivley Mar 15, 2021
@cherrymui cherrymui added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Mar 15, 2021
@cherrymui cherrymui added this to the Backlog milestone Mar 15, 2021
@seankhliao
Copy link
Member

Duplicate of #43854

The * pattern matches everything directly in the directory including . and _, the usual policy of ignoring . and _ then applies to all matched directories

@golang golang locked and limited conversation to collaborators Mar 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants