A Minimal Static File Server for Go Developers
When you're developing a web application locally, there comes a point where opening an HTML file directly in the browser isn't enough. Certain features simply don't work over the file:/// scheme:
- Web workers
- Web sockets
- WASM
- Separate API servers that require CORS
- Loading ES modules from separate files
In those cases you need a proper HTTP server for your static assets. The Python ecosystem had python -m SimpleHTTPServer <port>, which worked but wasn't very configurable and required Python to be installed. In the Node.js world, http-server has been a popular choice—run it via npx with no installation and configure it purely through command-line flags.
That Node.js tool inspired a new option for Go developers: static-server. It addresses a common gap—not all Go developers have npm or npx installed, and digging through JavaScript to tweak a server isn't ideal for many in the Go community. The Node.js-based server comes with 13 dependencies, making its codebase fragmented across helper packages and hard to modify.
Running It
If Go is installed, there's nothing extra to download. To serve the current directory:
$ go run github.com/eliben/static-server@latest
Run it with -help for usage information. There are no configuration files—the defaults are useful immediately, and command-line flags let you adjust what you need. For repeated use, install it once:
$ go install github.com/eliben/static-server@latest
Then invoke static-server directly, assuming your PATH includes Go's binary directory.
Why It's Different
Serving static files in Go is straightforward. The simplest possible server for the current working directory is only a few lines:
package main
import "net/http"
func main() {
port := ":8080"
handler := http.FileServer(http.Dir("."))
http.ListenAndServe(port, handler)
}
The problem was that this small server.go file kept getting copied into projects unchanged. Static-server formalizes that pattern into a single, reusable tool. It does the right thing with no flags, but supports common needs: configuring the port, enabling CORS, serving over TLS, and controlling log output.
The implementation is intentionally easy to understand. All code lives in one file—under 200 lines including comments and flag handling—with zero runtime dependencies. A single testing package is the only exception.
Design Priorities
Static-server takes its cues from the Node.js http-server project but drops the dependency sprawl. Everything is contained, readable, and modifiable. For Go developers who need a quick, hackable way to serve static content during development, it's a tool worth keeping in the toolbox.



