Use the embed.FS type to declare a variable that embeds a directory of files at compile time, making them accessible via the io/fs interface.
package main
import (
"embed"
"fmt"
"io/fs"
)
//go:embed assets/*
var Content embed.FS
func main() {
files, _ := fs.Glob(Content, "assets/*.txt")
fmt.Println(files)
}
The //go:embed directive must precede the variable declaration and specify the path pattern relative to the source file.