I'd like to have a single binary for a go-app, rather than having to bundle static files alongside the deployment.
I'm using a function like this to access PNGs I'm loading:
func getFileList(dir string) (fileList []os.FileInfo, err error) {
// USAGE:
// fileList,_ := getFileList(PNG_DIR)
f, err := os.Open(PNG_DIR)
defer f.Close()
checkErr(err)
fileList, err = f.Readdir(0)
checkErr(err)
return fileList, err
}
I take this list of files and serve it on a static endpoint, with some logic.
I have read the following documentation for using go-assets
- https://github.com/jessevdk/go-assets-builder/blob/master/builder.go
- https://github.com/jessevdk/go-assets-builder
- https://github.com/jessevdk/go-assets/blob/master/generate.go
As well as this gin specific example:
- https://github.com/gin-gonic/gin/blob/master/examples/assets-in-binary/assets.go
- https://github.com/jessevdk/go-assets/blob/master/example_test.go
- https://github.com/gin-gonic/gin/tree/master/examples/assets-in-binary
Which contains the following example:
Prepare Packages
go get github.com/gin-gonic/gin go get github.com/jessevdk/go-assets-builder
Generate assets.go
go-assets-builder html -o assets.go
Build the server
go build -o assets-in-binary
Run
./assets-in-binary
However, it's not clear to me how to call this file I have built. For example, What do I change in my getFileList()
function to now point to whatever I built in the binary, what is it even called and how would I know that?