The static directory contains static content. This content is used alongside the content in the main Go repository by the golangorg binary when serving the website. The details of the directory to path mapping are documented at the top of cmd/golangorg/main.go.

TODO(dmitshur): The process below can be simplified. See

Development mode

In production, CSS/JS/template assets need to be compiled into the golangorg binary. It can be tedious to recompile assets every time, but you can pass a flag to load CSS/JS/templates from disk every time a page loads:

golangorg -templates=$GOPATH/src/ -http=:6060

Recompiling static assets

Files such as static/style.css, static/doc/copyright.html and so on are not present in the final binary. They are embedded into static/static.go by running go generate. To compile a change and test it in your browser:

  1. Make changes to an existing file such as static/style.css.

  2. If a new file is being added to the static directory, add it to the files slice in static/internal/gen/gen.go.

  3. Run go generate so static/static.go is up to date.

  4. Run go run -http=:6060 and view your changes in the browser at http://localhost:6060. You may need to disable your browser's cache to avoid reloading a stale file.

A test exists to catch a possible mistake of forgetting to regenerate static assets:

website $ go test ./...
--- FAIL: TestStaticIsUpToDate (0.06s)
    gen_test.go:27: static.go is stale.  Run:
          $ go generate
          $ git diff
        to see the differences.
FAIL	0.650s