Im using go's net/http library to serve up a web app. When users come to the site, they can simply go to /, and it serves index.html (like any site).
This is implemented using:
r.PathPrefix("/").Handler(http.FileServer(http.Dir("./")))
However, there are two ways to structure such an app. First you could pack all the files in the same directory. This seems to me to be a unstable solution (if I run the go file directly it fails).
src/bin/app.go
src/bin/index.html
Or, the more "traditional" style, where index.html is top level.
src/bin/app.go
index.html
- Where is the right place for index.html, or other static resources in a go web app ?
- How is the location of ./ determined once we pack a go file into a binary ?
- Can a go binary file preserve a directory structure of non go resources so that this is consistent between dev and production environments?
Aucun commentaire:
Enregistrer un commentaire