GO tooling and library for embedding zip files inside existing binaries.
spsobole 95b7d07e91 overlay.go | 2 months ago | |
---|---|---|
cmd | 2 years ago | |
example | 3 years ago | |
.gitignore | 3 years ago | |
README.md | 4 years ago | |
build.yaml | 3 years ago | |
bundle.go | 2 years ago | |
go.mod | 3 years ago | |
go.sum | 3 years ago | |
http_dir.go | 2 months ago | |
http_file.go | 2 years ago | |
http_fs.go | 2 years ago | |
log.go | 4 years ago | |
overlay.go | 2 years ago | |
vessel.go | 4 years ago | |
vessel_test.go | 2 years ago |
Implements a golang library and command line tool for embedding contents of a zip file into a golang binary for the purpose of packing the binary and content into a single file for distribution.
The zip file is appended to the back of the binary, and the provided API allows us to access the zipped files directly.
In the example below, vesselcmd will zip up the content of site/ and attach it to the golang binary server
./vesselcmd build --overwrite --bundle=./server.exe --src=site/
Once bundled the golang program can acess the content via:
b, err := vessel.Self()
if err != nil {
panic(err)
}
fs := b.FileSystem() // this returns an http.FileSystem
We can then directly use the returned filesystem to serve http pages/content
http.Handle("/", http.FileServer(fs))
Or we can access the files ourselves by using the http.FileSystem interfaces
f, err := fs.Open("/templates/list.html")
if err != nil {
return err
}
defer f.Close()
data, err := ioutil.ReadAll(f)