My project structure is as follows:
/rootfolder
index.html
main.js
main.go
I'm trying to serve the static javascript file through FileServer(), which always returns the index.html as a response instead of the main.js
In main.go:
serveFile := http.StripPrefix("/res/", http.FileServer(http.Dir(".")))
http.HandleFunc("/", indexHandler)
http.Handle("/res", serveFile)
http.ListenAndServe(":8080", nil)
Inside index.html main.js is referenced as follows:
<script src="/res/main.js"></script>
From the network tab in my browser, it appears that FileServer() is always returning the index.html file as a response to /res/main.js