Skip to content

embed: go get and go.work disagree on what is included in an embed.FS #71978

@jsteenb2

Description

@jsteenb2

Go version

go version go1.24.0 darwin/arm64

Output of go env in your module/workspace:

AR='ar'
CC='cc'
CXX='c++'
GCCGO='gccgo'
GO111MODULE='on'
GOARCH='arm64'
GOARM64='v8.0'
GOAUTH='netrc'
GOBIN='***'
GOCACHE='***'
GOCACHEPROG=''
GODEBUG=''
GOENV='***'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/nc/_09t16c10vl89ld5s0jkkg3h0000gn/T/go-build1473942521=/tmp/go-build -gno-record-gcc-switches -fno-common'
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMOD='/dev/null'
GOMODCACHE='***'
GONOPROXY='***' # lists our local VCS
GONOSUMDB='***' # lists our local VCS
GOOS='darwin'
GOPATH='***'
GOPRIVATE='***' # lists our local VCS
GOPROXY='***' # lists our local VCS proxy
GOROOT='/opt/homebrew/Cellar/go/1.24.0/libexec'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTMPDIR=''
GOTOOLCHAIN='local'
GOVCS=''
GOVERSION='go1.24.0'
GOWORK=''

What did you do?

When working with the //go:embed, I ran into an issue where it performed differently when working locally with go.work vs pulling the module using go get.

I have created a reproduction of the issue using a couple of modules:

For context, the embedvendor is representing a server that we created for tests that acts like it is accessing a VCS server. We utilize this across other modules. There are no go files in the vendor directories.

What did you see happen?

I have the getvendor module that depends on embedvendor. Everything works as expected when working with go.work accessing it from my local development environment. However, when I use go get to pull the module, the embed.FS within embedvendor is missing entire paths that include **/vendor/** in it.

I set up a test in embedvendor/fs_test.go to validate the entire embed.FS is available. It passes as expected.

However, inside getvendor/fs_test.go, I get a failure indicating the paths with vendor/ in it are missing.

If you add the go.work into the getvendor module and wire in the embedvendor from your filesystem, the tests pass. This disagreement was jarring and took a good while to determine.

What did you expect to see?

I expected the getvendor to have access to the entire embed.FS.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions