Skip to content
Code & Tools

A Small Go Server for Static Previews

Theo Marsh
1 min read
40
Cover photo for “A Small Go Server for Static Previews”

We wanted a preview server that anyone in the studio could run without installing anything. Go made that easy.

Most of the improvement in a draft comes from cutting. We aim to remove a fifth of every piece on the second pass, and the reader never misses it.

We schedule unstructured time on purpose. Some of our best ideas started as an afternoon with no plan and a stack of old magazines.

preview.go
package main

import (
	"log"
	"net/http"
)

func main() {
	fs := http.FileServer(http.Dir("./public"))
	http.Handle("/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		w.Header().Set("Cache-Control", "public, max-age=60")
		fs.ServeHTTP(w, r)
	}))
	log.Fatal(http.ListenAndServe(":8000", nil))
}
Go UTF-8·LF·15 lines

We keep a running document of things that went wrong on past projects. It is not a list of failures so much as a list of warnings, and we read it before every kickoff.

Constraints are underrated. A fixed word count, a single typeface, or a two-colour palette forces decisions that an open brief lets you postpone forever.

Every studio accumulates habits it never chose. Once a year we list them and ask whether each one still earns its place.

9
Continue reading

Related posts

All posts
Conversation

Comments · 9

Posting as guest · Sign in
  1. Sam Achebe ·

    Such a clear explanation. I finally understand why our pages felt sluggish on mobile.

  2. Daniel Osei ·

    Such a clear explanation. I finally understand why our pages felt sluggish on mobile.

  3. Rafael Costa ·

    Small typo in the third paragraph, but otherwise a perfect read with my morning coffee.

  4. Maya Lindqvist ·

    Do you have a recommendation for someone just starting out? Everything I find assumes years of experience.

  5. Daniel Osei ·

    Do you have a recommendation for someone just starting out? Everything I find assumes years of experience.

  6. Daniel Osei ·

    Would love a follow-up post on how you organise all of this afterwards.

  7. Priya Raman ·

    We adopted the no-email-before-ten rule after your last post. Our mornings are so much calmer.

    1. Aiko Tanaka ·

      Fair point. We went back and forth on that one in the studio.

  8. Tom Adeyemi ·

    This is exactly the nudge I needed this week. Printing the checklist and taping it above my desk.