8000 cmd/go: embed directory fails when at / · Issue #49570 · golang/go · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
cmd/go: embed directory fails when at / #49570
Closed
@thomaspeugeot

Description

@thomaspeugeot

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 "/"

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0