Help us shape the future of Go! Take the 2026 Go Developer Survey

codebase

package
v0.0.20 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package codebase builds a Codebase from config: the in-memory kind (the default), a plain directory, or a git working tree, each composed with the foundation/codebase views and run through the client tier (Decorate). The sources live in the memory/, fs/ and git/ subpackages.

Index

Constants

View Source
const (
	// KindMemory serves Deps.Files from memory (the default).
	KindMemory client.Kind = "memory"

	// KindFS serves every file under Config.Root except `.git`.
	KindFS client.Kind = "fs"

	// KindGit serves the git working tree at Config.Root: tracked plus untracked,
	// non-ignored files.
	KindGit client.Kind = "git"
)

Variables

This section is empty.

Functions

func Decorate

func Decorate(
	base interfaces.Codebase,
	decs decorate.Decorations,
	name string,
	opts ...client.Option,
) (interfaces.Codebase, error)

Decorate runs every Codebase operation of base through the client tier as the client named name: files, text, match, changed and rendered. Go and YAML return base's views, whose reads go through the same memo.

func NewFromConfig

func NewFromConfig(
	ctx context.Context,
	cfg Config,
	deps Deps,
) (interfaces.Codebase, error)

NewFromConfig builds the codebase cfg.Kind selects and runs it through the client tier. An unknown kind, or a kind missing its root or runner, is CodeInvalidInput.

Types

type Config

type Config struct {
	// Kind selects the source; empty means KindMemory.
	Kind client.Kind `yaml:"kind" mapstructure:"kind"`

	// Name labels the client in decoration overrides, metrics, spans and logs; empty
	// uses the family name ("codebase").
	Name string `yaml:"name" mapstructure:"name"`

	// Root is the repository root for KindFS and KindGit.
	Root string `yaml:"root" mapstructure:"root"`
}

Config selects and locates the repository.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns the memory kind.

type Deps

type Deps struct {
	// Decorations decorates the client from the decoration config and supplies its
	// observability.
	decorate.Decorations

	// Runner runs git for KindGit.
	Runner interfaces.CommandRunner

	// Renderer renders charts for Rendered; nil makes Rendered CodeUnavailable.
	Renderer interfaces.Renderer

	// Snapshot is the run's memo; nil starts a new one keyed by Config.Root.
	Snapshot *views.Snapshot

	// Files are KindMemory's contents, by repository-relative path.
	Files map[string]string
}

Deps carries the codebase's runtime collaborators.

Directories

Path Synopsis
Package fs is the plain-directory CodebaseSource: every file under a root, except the `.git` directory, with no version control.
Package fs is the plain-directory CodebaseSource: every file under a root, except the `.git` directory, with no version control.
Package git is the git working-tree CodebaseSource: the files git tracks plus the untracked files it does not ignore, read from disk, with Changed answered by `git diff --merge-base`.
Package git is the git working-tree CodebaseSource: the files git tracks plus the untracked files it does not ignore, read from disk, with Changed answered by `git diff --merge-base`.
Package memory is the in-memory CodebaseSource: a map of root-relative paths to contents, with no version control.
Package memory is the in-memory CodebaseSource: a map of root-relative paths to contents, with no version control.

Jump to

Keyboard shortcuts

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