A library to help with the management of serving static files.
It builds on top of any Go's standard
fs.FS interface implementation and, it provides a method to overlay
a different file structure on top of what the underlying fs exposes. We call this an "asset group".
It includes its own
fs.FS implementation, which can be generated using
//go:generate, and has a small advantage
over the standard
//go:embed mechanism by providing an API to pipeline functionality at resource compile time.
It currently supports filtering out files, and processing the remaining ones using a simple API.
See the examples folder for ways to use this.
The asset group maps one to one with the files in the example's
In this example the exposed entries of the asset group are each composed of multiple "pieces",
each of them represented by a file in the
/main.js ├─ ./static/js/hello.js └─ ./static/js/world.js
This is an example closer to real world usage where we embed the contents of the files in the
//go:embed if we run/compile the example using the
prod build tag, or we use the
method we saw in example 1.
This example was born out of the need of adding some processing steps for the contents of the files, which can not be
done using the standard
Instead of requiring the asset group in the consumer code, we can generate it directly containing our desired structure.
We bundle all the following files into just one that can be accessed at
./static/ └── js ├── assets.js ├── group.js └── hello.js