Limitations of go

embed and How to Work Around Them

go:embed fails on files over 2GB or with invalid paths; load large assets at runtime using standard file I/O instead.

go:embed cannot embed files larger than 2GB, cannot embed files with names containing backslashes, and cannot embed files from outside the module directory at compile time. Use archive/zip or archive/tar to bundle large or complex file sets at runtime instead of compile time.

import (
	"archive/zip"
	"io"
	"os"
)

func loadLargeAsset(path string) ([]byte, error) {
	f, err := os.Open(path)
	if err != nil { return nil, err }
	defer f.Close()
	return io.ReadAll(f)
}