bundle

package
v0.4.3 Latest Latest
Warning

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

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

Documentation

Overview

Package bundle computes a content digest over a tree of files, so that the frontend compiled into the binary can be compared with the one on disk.

It exists because go:embed reads web/dist at COMPILE time. A binary built before the frontend was rebuilt carries the older bundle, serves it happily, and passes every health check — the E2E suite then fails against a UI that no longer matches the source, and the failures look like anything except what they are. That has happened twice here: once as stale-at-build (the binary compiled before `npm run build`) and once as stale-after-rebase (the bundle left over from before a rebase), the second costing eight phantom E2E failures before anyone suspected the bundle.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Count

func Count(fsys fs.FS) (int, error)

Count reports how many regular files fsys holds. It is only used to make a mismatch message concrete ("142 files" against "1 file" says immediately that a stub dist was embedded, which a pair of hashes does not).

func Digest

func Digest(fsys fs.FS) (string, error)

Digest returns a hex-encoded SHA-256 over every regular file in fsys.

Both the path and the content of each file go into the hash, in sorted path order, each length-delimited. The path matters because otherwise moving bytes between two files would not change the digest; the length delimiter matters because otherwise concatenation is ambiguous — "ab" + "c" and "a" + "bc" would hash alike.

Directories contribute nothing. An empty one is not a difference worth failing a build over, and go:embed would not carry it across anyway, so counting it would make the two sides disagree for no reason.

Types

This section is empty.

Jump to

Keyboard shortcuts

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