I have this directory structure
src/
github.com/
john/
site/
main.go
templates/
index.html
static/
js/
site.js
css/
In my main.go:
func main() {
http.Handle("/templates/", http.StripPrefix("/templates/", http.FileServer(http.Dir(filepath.Join(cwd, "/github.com/john/site/templates/"))))
http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir(filepath.Join(cwd, "/github.com/john/site/static/"))))
In index.html
<script src="/static/js/site.js"></script>
The HTML loads properly. However, no such js file was found. Why is that so?
I run go install within the src
directory. Also, when I try to access localhost:3000/templates/index.html, the file is not found either.