Serving a map of strings using http.FileSystem and http.Handle

(GoNomad) #1

I am just starting out with Go and am trying to learn how to build a simple web app without using 3rd party libraries / packages.

Using this post and this code as a guideline, I’ve hacked the following together:

Which compiles fine (locally, not on the Go Playground), but doesn’t actually produce any results other than 404 page not found…

What I want to achieve is having a package in my app that allows me to make a map, embed some static content such as css and js in it and then serve it with http.Handle - Without using 3rd party tools like go-bindata, rice or anything else.

Any help would be greatly appreciated…

(GoNomad) #2

Problem solved;

Turns out index.html isn’t working as the browser interprets this as “/” and by using a leading slash prior to the file name it now works.

See: my post on stackoverflow where the user ‘Gavin’ and the user ‘YongHao Hu’ were nice enough to help.