Using Go embed to bundle your content
In this section, we will look at how to package applications into a single binary. Packaging everything the application needs into a single binary makes it easier to deploy the application anywhere in the cloud. We are going to use the embed
package that is provided by the Go standard library. The following link provides further detail on the different functions available inside the embed package: https://pkg.go.dev/embed.
Note
The embed package is only available in Go version 1.16 and upwards.
The following code provides a simple example of using the embed package in three different ways – to embed a specific file, embed the full contents of a folder, and embed a specific file type:
1 package main 2 3 import ( 4 "...