including templates in the dev.golang binary

175 views
Skip to first unread message

kbur...@gmail.com

unread,
Jan 8, 2017, 4:02:07 PM1/8/17
to golang-dev
Right now golang.org/x/build/devapp includes two HTML files by loading them from disk at runtime, meaning you have to start the binary from the correct directory and ensure that the HTML files are present on disk.

func showDash(w http.ResponseWriter, req *http.Request) {
// ...

tmpl, err := ioutil.ReadFile("template/dash.html")
if err != nil {
log.Errorf(ctx, "reading template: %v", err)
return
}
t, err := template.New("main").Funcs(template.FuncMap{
"css":     d.css,

I'd like to compile these into the binary, so deployment is simpler. 


I could port that, but there is a 3rd party tool for embedding static files in a binary - github.com/jteeuwen/go-bindata - that would 1) compress the contents of assets before storing them, doesn't require manual management of the file list, and 2) remove the need for the go:generate directive and BOM hacking code in makestatic.go.

- What are your thoughts on using that tool in both places?

- If "let's use it" what is the policy for including 3rd party libraries in golang tools? OK as long as the author signs a CLA & library is available under a permissive license?

- If "let's not use it", is there another tool I'm missing where static files are compiled into a binary?

- Is this the best place to get feedback while I'm working on improvements to dev.golang.org? Alternatives would be emailing someone directly who'd be reviewing patches, just submitting the patches, posting on Github, or posting to a different mailing list.

Dave Cheney

unread,
Jan 8, 2017, 4:06:55 PM1/8/17
to kbur...@gmail.com, golang-dev

This won't need a complicated tool, just move those files into constants inside the package.


--
You received this message because you are subscribed to the Google Groups "golang-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages