packageasset

package
v1.1.0 Latest Latest
Warning

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

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

Documentation

Overview

Package packageasset discovers and snapshots Go embedded resources.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExpandSourceResources added in v1.1.0

func ExpandSourceResources(directory string, patterns []string) ([]string, error)

ExpandSourceResources follows Go embed file/directory/glob selection. Missing literal files remain explicit so snapshot loading reports the broken contract.

func SourceEmbedFiles added in v1.1.0

func SourceEmbedFiles(directory string, content []byte) ([]string, error)

SourceEmbedFiles returns the assets named by a Go file's embed directives. It is also used to retire templates referenced by obsolete generated code.

Types

type File

type File struct {
	Path string
	Data []byte
}

File is a virtual source file supplied before an immutable snapshot is published.

type Resources

type Resources struct {
	Namespace string
	Files     []string
	// SourceFile and Symbol come from the current Go embed declaration.
	SourceFile string
	Symbol     string
}

func DiscoverSourceResources

func DiscoverSourceResources(directory string) ([]*Resources, error)

DiscoverSourceResources finds generated go:embed declarations in a package.

func (*Resources) Validate

func (r *Resources) Validate() error

type Snapshotter

type Snapshotter struct {
	Source  fs.FS
	Overlay []File
}

Snapshotter creates a completed filesystem for one unpublished generation. Standard-library archive storage retains all bytes without fabricating embed internals.

func (Snapshotter) All

func (s Snapshotter) All(ctx context.Context) (fs.FS, error)

func (Snapshotter) Files

func (s Snapshotter) Files(ctx context.Context, files []string) (fs.FS, error)

func (Snapshotter) Folder

func (s Snapshotter) Folder(ctx context.Context, root string) (fs.FS, error)

Folder snapshots an explicit subtree for both generated embedding and MCP. Filesystems supplied directly must be immutable; development OS callers use os.Root.

type StaticSource

type StaticSource struct {
	// LocalRoot is an optional caller-owned authority selected independently of
	// ContentURL. Local ContentURL must be relative to it. The caller must keep it
	// open through staging and must not derive it by following configured paths.
	// Nil uses the volume root for absolute paths, or cwd for relative paths.
	LocalRoot  *os.Root
	Resources  *resource.Store
	ContentURL string
}

StaticSource resolves static authority once per generation. Local OS roots are confined while snapshotting; remote ContentURL keeps AFS ownership.

func (StaticSource) Snapshot

func (s StaticSource) Snapshot(ctx context.Context, content *spec.StaticContent) (fs.FS, error)

Jump to

Keyboard shortcuts

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