Skip to content

embed: unable to read embedded files and directories #76184

@isacikgoz

Description

@isacikgoz

Go version

go version go1.25.1 darwin/arm64

Output of go env in your module/workspace:

AR='ar'
CC='cc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='c++'
GCCGO='gccgo'
GO111MODULE=''
GOARCH='arm64'
GOARM64='v8.0'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/Users/ibrahim/Library/Caches/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/Users/ibrahim/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/g2/dgdzq5s16r5gzxwkk3xv9vd00000gn/T/go-build1761144713=/tmp/go-build -gno-record-gcc-switches -fno-common'
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMOD='/dev/null'
GOMODCACHE='/Users/ibrahim/go/pkg/mod'
GONOPROXY='github.com/mattermost/*'
GONOSUMDB='github.com/mattermost/*'
GOOS='darwin'
GOPATH='/Users/ibrahim/go'
GOPRIVATE='github.com/mattermost/*'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/opt/homebrew/Cellar/go/1.25.1/libexec'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/Users/ibrahim/Library/Application Support/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='go1.25.1'
GOTOOLDIR='/opt/homebrew/Cellar/go/1.25.1/libexec/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.25.1'
GOWORK=''
PKG_CONFIG='pkg-config'

What did you do?

I have embedded sql queries in my Go application and we read those queries from embedded files during runtime. It's a standard embedding process with following snippet:

import "embed"

//go:embed *
var assets embed.FS

func Assets() embed.FS {
	return assets
}

And I am reading one of the directory as follows:

// assets is a embed.FS instance

queries, err := assets.ReadDir(path.Join("dir", "subdir"))
if err != nil {
	return err
}

What did you see happen?

If I compile this binary with GOTOOLCHAIN=go1.24.6 for example it works fine and the program is able to read files, but when I try compile with GOTOOLCHAIN=go1.25.1, program basically can't read any files without producing any errors. In the code snippet above queries returns an empty slice.

output_compile_go1.24.6.txt

output_compile_go1.25.1.txt

What did you expect to see?

Embedded files should be accessible regardless of the toolchain as I couldn't find any related release note regarding to the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugReportIssues describing a possible bug in the Go implementation.WaitingForInfoIssue is not actionable because of missing required information, which needs to be provided.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions