assets

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 13, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package assets is the runtime helper a Go web app uses to consume pin's output: parse the lockfile, serve the vendored files, and emit HTML tags with integrity attributes.

Imports only lock — no fetcher, no HTTP — so servers that only render templates stay lean.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FS

func FS(fsys fs.FS, l *Lock) (fs.FS, error)

FS returns a sub-filesystem rooted at the lockfile's out directory. Pass an embed.FS that includes the vendored tree at outDir.

func SRI

func SRI(l *Lock, name string) string

SRI returns the Subresource Integrity string for the named package's first file, suitable for direct use in a <script integrity=""> attribute when rendering tags by hand.

func Tag

func Tag(l *Lock, name string, opts Options) []template.HTML

Tag returns one HTML tag per file the named package vendored, in lockfile order. Use this when load order matters.

func Tags

func Tags(l *Lock, assetType string, opts Options) []template.HTML

Tags returns one HTML tag per file of the given asset type, in lockfile (alphabetic) order. Fine for fonts and images; not recommended for stylesheets or scripts where load order matters.

Types

type Asset

type Asset = lock.Asset

type Lock

type Lock = lock.Lock

func Parse

func Parse(r io.Reader) (*Lock, error)

Parse reads a pin.lock CycloneDX BOM into a flat Lock model.

type Options

type Options struct {
	// Prefix is prepended to each asset's out path. Typically the
	// route a static file server is mounted under, e.g.
	// "/static/vendor/". No trailing slash is added.
	Prefix string
}

Jump to

Keyboard shortcuts

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