Allows file embedding into a Go binary.
Forklift is a library and an utility inspired by gotic.
The lib forklift/files provides an API to access files.
The utility forklift generates Go code from files and embbed them into the binary for caching.
To install Forklift:
go get -u github.com/solher/forklift
A file.sql file located (for example) in the same directory as the main.go file:
SELECT * FROM documentsThe main.go file:
package main
import "github.com/solher/forklift/files"
func main() {
println(files.File("file.sql"))
}
// Prints: SELECT * FROM documentsBy default (development), the file will actually be read from the disk. In production, you can embbed the files into the binary by running the command:
$ forklift -extensions sql,gql > forklift.goThe files will then be read from memory.