-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add embed example for go 1.16 #1175
Conversation
Thanks for opening this pull request! 🎉 Please check out our contributing guidelines. If you need help or want to chat with us, join us on Discord https://gofiber.io/discord |
That was fast, thank you! Can we also put a notice about recommending this over the other solutions listed?
|
Added 👍 |
Congrats on merging your first pull request! 🎉 We here at Fiber are proud of you! If you need help or want to chat with us, join us on Discord https://gofiber.io/discord |
Good idea, but seems needed to make an example to embed a static tree, not only one file, I'm stuck in that right now. Thanks! |
Please, note this in order to serve a directory tree: //go:embed public
var public embed.FS
subFS, _ := fs.Sub(public, "public")
app.Use("/", filesystem.New(filesystem.Config{
Root: http.FS(subFS),
})) |
Thank you so much for this merge. I was looking for something exactly like this to serve static assets from an embedded filesystem. |
Go embedding was released in Go 1.16 yesterday. This PR is to add an example for how to use it with the filesystem middleware