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: unable to embed __init__.py via embed.fs #58354

Closed
gucio321 opened this issue Feb 6, 2023 · 3 comments
Closed

embed: unable to embed __init__.py via embed.fs #58354

gucio321 opened this issue Feb 6, 2023 · 3 comments

Comments

@gucio321
Copy link

gucio321 commented Feb 6, 2023

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

$ go version
go version go1.19.2 linux/amd64

Does this issue reproduce with the latest release?

deffinitly

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/me/.cache/go-build"
GOENV="/home/me/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/me/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/me/go"
GOPRIVATE=""
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.19.2"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
GOWORK=""
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 -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build3907440111=/tmp/go-build -gno-record-gcc-switches"

What did you do?

I need to embed a python code into my application.
It didn't work. After some investigation on my side, I've realised that go:embed directive does not embed (rather important) __init__.py file.
Is it any exception? And if so, should it be this way?

What did you expect to see?

everything should work as expected

What did you see instead?

unable to access file.

@earthboundkid
Copy link
Contributor

It is documented that names beginning with underscore are excluded by default.

@ALTree
Copy link
Member

ALTree commented Feb 6, 2023

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’.

https://pkg.go.dev/embed#hdr-Directives

Assuming your code doesn't do this (but we don't know since you didn't include it), try it.

@ALTree ALTree closed this as completed Feb 6, 2023
@gucio321
Copy link
Author

gucio321 commented Feb 6, 2023

oh, thank you very much!

@golang golang locked and limited conversation to collaborators Feb 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants