Chapter 12.
File embedding
The Go standard library includes an embed
package, which makes it possible to embed external files into your Go program itself.
Using the embed
package opens up the opportunity to create Go programs which are self-contained and have everything that they need to run as part of the compiled binary executable. In turn, that makes it easier to deploy or distribute your web application.
In this section of the book, we’ll update our application so that it embeds the files from our ui
directory — starting with the static CSS, JavaScript and image files, and then moving on to the HTML templates.
Let’s jump straight in and explain how to use it.