fingerprint

package
v0.36.0 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package fingerprint provides content-based static asset fingerprinting.

It walks a source directory, hashes each file's contents (SHA-256, first 12 hex chars), and writes fingerprinted copies (name.HASH.ext) to a separate output directory. A generated Go source file maps original paths to fingerprinted paths at compile time.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clean

func Clean(distDir string) error

Clean removes the dist directory entirely.

func IsFingerprinted

func IsFingerprinted(path string) bool

IsFingerprinted reports whether the given URL path contains a fingerprint hash.

Types

type Manifest

type Manifest struct {
	Files map[string]string
}

Manifest maps original relative paths to their fingerprinted counterparts.

func Fingerprint

func Fingerprint(srcDir, distDir string) (*Manifest, error)

Fingerprint walks srcDir, hashes each file, and writes fingerprinted copies to distDir (mirroring the directory structure). The distDir is wiped first to remove stale files from previous runs.

func (*Manifest) WriteGoManifest

func (m *Manifest) WriteGoManifest(path, pkg string) error

WriteGoManifest writes a Go source file declaring a StaticManifest variable with the manifest entries baked in as a map literal.

Jump to

Keyboard shortcuts

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