statik allows you to embed a directory of static files into your Go binary to be later served from an http.FileSystem. Is this a crazy idea? No, not necessarily. If you're building a tool that has a Web component, you typically want to serve some images, CSS and JavaScript. You like the comfort of distributing a single binary, so you don't want to mess with deploying them elsewhere. If your static files are not large in size and will be browsed by a few people, statik is the solution you are looking for. statik is a tiny program that reads a directory and generates a source file that contains its contents. The generated source file registers the directory contents to be used by statik file system. In your program, all your need to do is to import the generated package, initialize a new statik file system and serve.
Features
- By default, statik includes the "last modified" (mtime) time on files that it packs
- Allows an HTTP FileServer to present the correct file modification times to clients
- You can also read the content of a single file
- statik is a tiny program that reads a directory and generates a source file that contains its contents
- The generated source file registers the directory contents to be used by statik file system
- The command below will walk on the public path and generate a package called statik under the current working directory