Closed tj closed 6 years ago
I believe this is already possible and can even work without the packr binary installed.
Here is a working example: https://github.com/twirphp/twirp/commit/4b6852129e505375ca96e090440fc1044fce15f1
It might be a good idea to document this, so packr can reach a higher score in this wonderful post:
http://tech.townsourced.com/post/embedding-static-files-in-go/
//go:generate packr2 -v
package main
import (
"net/http"
"github.com/gobuffalo/packr/v2"
)
func main() {
box := packr.New("my box", "./templates")
http.Handle("/", http.FileServer(box))
http.ListenAndServe(":3000", nil)
}
This definitely works in v2. Closing this, please re-open if it's still an issue. Thanks.
Looks like a nice replacement for go-bindata! But it seems to not allow you to use it with go:generate, unless that wasn't the intent. It'd be awesome to just drop
// go:generate packr
in there.go-bindata had a few weird defaults so you always have to specify flags, I usually end up doing this if checked into source:
or I guess just:
if it's not checked into GIT, but I think the CWD and name could be inferred easily and would be a nicer experience
cheers!