# How to load embed library with multiple files

**URL:** <https://forum.golangbridge.org/t/how-to-load-embed-library-with-multiple-files/35929>\
**Category:** Getting Help\
**Created:** [August 11, 2024, 2:15pm UTC](https://forum.golangbridge.org/t/how-to-load-embed-library-with-multiple-files/35929 "2024-08-11T14:15:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![packs](https://forum.golangbridge.org/user_avatar/forum.golangbridge.org/packs/32/9635_2.png) [@packs](https://forum.golangbridge.org/u/packs)\
**Post date:** [August 11, 2024, 2:15pm UTC](https://forum.golangbridge.org/t/how-to-load-embed-library-with-multiple-files/35929/1 "2024-08-11T14:15:40Z")

</div>

//go:embed sqls/allquery.sql

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

How to implement with multiple files

---

<div class="post-metadata">

**Author:** ![pekim](https://forum.golangbridge.org/user_avatar/forum.golangbridge.org/pekim/32/14094_2.png) [@pekim](https://forum.golangbridge.org/u/pekim)\
**Post date:** [August 11, 2024, 3:26pm UTC](https://forum.golangbridge.org/t/how-to-load-embed-library-with-multiple-files/35929/2 "2024-08-11T15:26:08Z")

</div>

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
//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)

```

---

<div class="post-metadata">

**Author:** ![packs](https://forum.golangbridge.org/user_avatar/forum.golangbridge.org/packs/32/9635_2.png) [@packs](https://forum.golangbridge.org/u/packs)\
**Post date:** [August 11, 2024, 5:58pm UTC](https://forum.golangbridge.org/t/how-to-load-embed-library-with-multiple-files/35929/3 "2024-08-11T17:58:36Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![falco467](https://forum.golangbridge.org/user_avatar/forum.golangbridge.org/falco467/32/13340_2.png) [@falco467](https://forum.golangbridge.org/u/falco467)\
**Post date:** [August 12, 2024, 10:16am UTC](https://forum.golangbridge.org/t/how-to-load-embed-library-with-multiple-files/35929/4 "2024-08-12T10:16:10Z")

</div>

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](https://gobyexample.com/embed-directive)

---

<div class="post-metadata">

**Author:** ![system](https://forum.golangbridge.org/uploads/default/original/2X/5/5ad234f7c3dbc68b6cc72d338ce4f2973d9fd81c.png) [@system](https://forum.golangbridge.org/u/system)\
**Post date:** [November 10, 2024, 10:16am UTC](https://forum.golangbridge.org/t/how-to-load-embed-library-with-multiple-files/35929/5 "2024-11-10T10:16:19Z")

</div>

Closed on November 10, 2024, 10:16am UTC

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