Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot declare multiple directories with go-bindata-assetfs or a single child. #58

Open
joegasewicz opened this issue Apr 12, 2022 · 0 comments

Comments

@joegasewicz
Copy link
Contributor

joegasewicz commented Apr 12, 2022

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()
}
joegasewicz added a commit to ONSdigital/go-bindata-assetfs that referenced this issue Apr 12, 2022
@joegasewicz joegasewicz changed the title Cannot declare multiple directories with go-bindata-assetfs Cannot declare multiple directories with go-bindata-assetfs or a single child. Apr 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant