Skip to content

Go embed does not see dot files inside dot directory #46986

@renta

Description

@renta

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

$ go version
go version go1.16.5 linux/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="/home/vasiliy/.cache/go-build"
GOENV="/home/vasiliy/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/vasiliy/go/pkg/mod"
GONOPROXY="my-company-repo.example"
GONOSUMDB="my-company-repo.example"
GOOS="linux"
GOPATH="/home/vasiliy/go"
GOPRIVATE="my-company-repo.example"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.16.5"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/vasiliy/projects/my-awesome-project/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 -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build3333807026=/tmp/go-build -gno-record-gcc-switches"

What did you do?

I try to use go:embed to include some file templates inside a service binary. Now the service structure looks like this:
|_internal
|__templates
|___files <- here I store project templates
|___files.go <- here project templates are embed

Code to embed subdirectory:

//go:embed files/*
templateFiles embed.FS

So inside the files directory I have a couple which path is:
.gitlab/helm/my-project/.helmignore <- this file cannot be found inside embed.FS
.gitlab/.gitlab-ci.yml <- this file cannot be found inside embed.FS

But there are no problems with files with paths like:
.gitlab/CODEOWNERS
.gitignore
.golangci.yml

So I suppose there is an issue with //go:embed mechanism when dot file is inside a dot directory.

What did you expect to see?

I hope to see all the files inside all the directories inside the embed.FS

What did you see instead?

There are no files with dots in filenames that has a dot directory inside their parents paths names.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions