imagecache

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package imagecache provides utilities for downloading and caching remote images.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultCacheDir

func DefaultCacheDir() (string, error)

DefaultCacheDir returns the default cache directory path.

func DownloadAndCache

func DownloadAndCache(ctx context.Context, url string, opts CacheOptions) (string, error)

DownloadAndCache downloads a remote image and saves it to the cache directory. Returns the local file path where the image was saved.

Types

type CacheOptions

type CacheOptions struct {
	// CacheDir is the directory where images will be cached.
	// If empty, defaults to ~/.cache/tinct/images
	CacheDir string

	// Filename is the filename to use for the cached image.
	// If empty, uses a hash of the URL + original extension.
	Filename string

	// AllowOverwrite determines if existing cached files can be overwritten.
	// Default: false (reuse existing cached files).
	AllowOverwrite bool
}

CacheOptions configures image caching behavior.

Jump to

Keyboard shortcuts

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