Help us shape the future of Go! Take the 2026 Go Developer Survey

cache

package
v1.12.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 8, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SHA256File

func SHA256File(path string) (string, error)

SHA256File computes the SHA256 hex digest of the file at path.

Types

type Cache

type Cache struct {
	// contains filtered or unexported fields
}

Cache is an in-memory SHA256 file cache backed by a JSON file on disk. It is safe for concurrent read access but writes must go through Mark/Save.

func Load

func Load(dir string) (*Cache, error)

Load reads the cache from dir/cache.json. If the file does not exist, an empty cache is returned. dir is created if it does not exist.

func (*Cache) DeletePrefix added in v1.3.0

func (c *Cache) DeletePrefix(prefix string) bool

DeletePrefix removes all cache entries whose path is rooted under prefix. It returns true when at least one entry was removed.

func (*Cache) IsCached

func (c *Cache) IsCached(path, sha string) bool

IsCached returns true if path has been processed with the given sha256 hash.

func (*Cache) Mark

func (c *Cache) Mark(path, sha string)

Mark records that path has been successfully processed with sha.

func (*Cache) Save

func (c *Cache) Save() error

Save writes the current cache entries to dir/cache.json.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL