Go embed example of serving static files at the root URL path
Go 1.16 introduced the embed package which allows serving static files from directly within the binary without the need for any external package.
Screenshot of the example web page Here are two example’s showing how to serve from the root URL path.
example.go shows an example of how to use the new io/fs package and the Sub func. The comments offer a word of caution however that it may not prevent access outside of the subdirectory.
Read more...