Embed SQL migration files in Go by adding them to your module's go.mod file using the embed directive and reading them at runtime via embed.FS.
//go:embed migrations/*.sql
var Migrations embed.FS
func GetMigration(name string) ([]byte, error) {
return Migrations.ReadFile("migrations/" + name)
}
Ensure your go.mod file includes go 1.16 or higher to support the embed package.