The Barista Logo


An i3status alternative in golang

Download sample-bar Download i3status example View on GitHub


import ""

The httpcache testing package provides a function to wrap an existing http.RoundTripper with a transport that caches responses to disk.

This cache is useful for quickly prototyping bar customisations. By replacing the Transport of http.DefaultClient (or replacing http.DefaultTransport), the resulting binary will no longer make real HTTP requests on each restart, so it can be rebuilt and restarted hundreds of times without consuming quota.

The cache is located at ~/.cache/barista/http (using XDG_CACHE_HOME for ~/.cache if set). Individual responses can be deleted if a fresher copy is needed.

Wrap(http.RoundTripper) http.RoundTripper: Returns a new http round tripper that caches responses to disk, and uses the passed-in round tripper to fetch initial responses.

To use it for a bar binary, it’s sufficient to add this to the main file:

import "net/http"
import ""

func init() {
	http.DefaultTransport = httpcache.Wrap(http.DefaultTransport)