I've followed the Writing Web Applications tutorial on the Go website and I'm starting to write my own web app. I've also read the beginning of How to Write Go Code and am trying to organise my code with the same workspace structure.
I'm writing a simple web app named mygosite that handles all requests by rendering a single template. After running
go install github.com/wesleym/mygosite, my directory structure now looks like this:
go +-src | +-github.com | +-wesleym | +-mygosite | +-mygosite.go | +-templates | +- index.html | +-.git +-bin +-mygosite
In my code, I'm referring to the template with path
templates/index.html. When I run
bin/mygosite, the app can't find my template because it's in the source tree. Since the templates are important to my app, I don't want to move them outside of my mygosite git repository.
Is my directory layout reasonable given what I'm trying to do? Should I change the path to my template in my code to be
tl;dr: Where do I put templates and static files in a Go web application project?