go-bindata-assetfs
go-bindata-assetfs copied to clipboard
Cannot declare multiple directories with `go-bindata-assetfs` or a single child.
Problem:
I want to declare multiple files when using the go-bindata-assetfs
cmd:
$ go-bindata-assetfs dist/... public/...
OR I want to only specify the dist
directory:
$ go-bindata-assetfs dist/...
But because the dist
directory has a public
directory sibling, the assetFS()
will randomly pick either the dist
or public
directory to generate from.
Issue:
The call to assetFS()
will randomly pass back only the first item in the _bintree.Children
slices, which means that if I pass a top level directory with multiple children directories assetFS()
will not return the desired results.
Requested changes:
I want to be able to define each static path to serve manually, either multiple of a single child directory. This example demonstrates serving 2 static directories but even if i just want to serve a single directory assetFS()
will not work if there are more than 1 directories present:
func main() {
r := mux.NewRouter() // Example uses "github.com/gorilla/mux"
// Here we want to serve static content from 2 directories
r.PathPrefix("/dist").Handler(http.StripPrefix("/dist", http.FileServer(AssetDIR("dist"))))
r.PathPrefix("/public").Handler(http.StripPrefix("/public", http.FileServer(AssetDIR("public"))))
// rest of server code...
server := &http.Server{ Addr: ":7777", Handler: r, }
server.ListenAndServe()
}