type cacheRoundTripper … // newCacheRoundTripper creates a roundtripper that reads the ETag on // response headers and send the If-None-Match header on subsequent // corresponding requests. func newCacheRoundTripper(cacheDir string, rt http.RoundTripper) http.RoundTripper { … } func (rt *cacheRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) { … } func (rt *cacheRoundTripper) CancelRequest(req *http.Request) { … } func (rt *cacheRoundTripper) WrappedRoundTripper() http.RoundTripper { … } type sumDiskCache … // Get the requested key from the cache on disk. If Get encounters an error, or // the returned value is not a SHA256 sum followed by bytes with a matching // checksum it will return false to indicate a cache miss. func (c *sumDiskCache) Get(key string) ([]byte, bool) { … } // Set writes the response to a file on disk. The filename will be the SHA256 // sum of the key. The file will contain a SHA256 sum of the response bytes, // followed by said response bytes. func (c *sumDiskCache) Set(key string, response []byte) { … } func (c *sumDiskCache) Delete(key string) { … } // Sanitize an httpcache key such that it can be used as a diskv key, which must // be a valid filename. The httpcache key will either be the requested URL (if // the request method was GET) or "<method> <url>" for other methods, per the // httpcache.cacheKey function. func sanitize(key string) string { … }