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

cmd/go: embed directory fails when at / #49570

Open
thomaspeugeot opened this issue Nov 13, 2021 · 1 comment
Open

cmd/go: embed directory fails when at / #49570

thomaspeugeot opened this issue Nov 13, 2021 · 1 comment

Comments

@thomaspeugeot
Copy link

@thomaspeugeot thomaspeugeot commented Nov 13, 2021

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

/ # go version
go version go1.16.10 linux/amd64

Does this issue reproduce with the latest release?

I do not know

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

go env Output
$ go env
 # go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/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.16.10"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build2312574173=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Training for docker with go, I forked github.com/olliefr/docker-gs-ping and added embed directive

//go:embed foo
var foo embed.FS

it worked fined in my working directory.
But when I configured Dockerfile for having everything at root, it did not work.

# Set destination for COPY
WORKDIR /

To reproduce the bug

git clone https://github.com/fullstack-lang/docker-gs-ping.git
cd docker-gs-ping
docker build --tag docker-gs-ping .

What did you expect to see?

a successfull go build

What did you see instead?

 > [7/8] RUN go build -o /docker-gs-ping:
#11 2.002 # github.com/olliefr/docker-gs-ping
#11 2.002 /main.go:14:5: embed oo/foo.txt: open /oo/foo.txt: no such file or directory

A workaround is to have the WORKDIR different from "/"

@seankhliao seankhliao changed the title go embed fails at root level (first character is mangled) cmd/go: embed directory fails when module root is at / Nov 13, 2021
@seankhliao seankhliao changed the title cmd/go: embed directory fails when module root is at / cmd/go: embed directory fails when at / Nov 13, 2021
@seankhliao
Copy link
Contributor

@seankhliao seankhliao commented Nov 13, 2021

Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants