How to load embed library with multiple files

//go:embed sqls/allquery.sql

I am using third party library sqload it is working with single file.

How to implement with multiple files

Unless I’m misunderstanding what you’re asking (as I’m not familiar with the sqload library), it’s as simple as embedding multiple files and using them.

//go:embed sqls/allquery.sql
var allQuery string

//go:embed sqls/someotherquery.sql
var someOtherQuery string

var q1 = sqload.MustLoadFromString[struct {
	...
}](allQuery)

var q2 = sqload.MustLoadFromString[struct {
	...
}](someOtherQuery)

Thank. I was trying by adding *.SQL and using single variable

You can also use embed with Wildcards like ./*.sql.
Then the variable has to be of type embed.FS

See: Go by Example: Embed Directive

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.