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

components

package
v1.0.14 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Copyright (c) 2025 Reliant Labs

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatComponentList

func FormatComponentList(entries []Entry) string

FormatComponentList formats a list of entries into a human-readable string grouped by category.

Types

type Category

type Category string

Category groups components by type.

const (
	CategoryLayouts  Category = "layouts"
	CategoryCharts   Category = "charts"
	CategoryDiagrams Category = "diagrams"
	CategoryDeck     Category = "deck"
	CategoryUI       Category = "ui"
)

Category enum values. Each value tags a component template with the kind of artifact it produces (HTML layout, SVG chart, diagram, deck slide, or generic UI primitive).

type Entry

type Entry struct {
	Name        string   `json:"name"`
	Category    Category `json:"category"`
	Description string   `json:"description"`
	Tags        []string `json:"tags"`
	FilePath    string   `json:"-"` // internal embed path
}

Entry describes a single component in the library.

type Library

type Library struct{}

Library provides access to the component library.

func NewLibrary

func NewLibrary() *Library

NewLibrary creates a new component library instance.

func (*Library) ByName

func (l *Library) ByName() map[string]*Entry

ByName returns the name-to-entry lookup map.

func (*Library) Dependencies added in v1.0.0

func (l *Library) Dependencies(name string) ([]string, error)

Dependencies returns every library component that name imports, directly or through another dependency, sorted. Components install into one flat directory, so a `./x` import is a sibling file the install must also write: installing `input` alone into an empty directory otherwise leaves an import of `./form_field_context` that does not resolve.

func (*Library) FindSimilar

func (l *Library) FindSimilar(name string) []string

FindSimilar returns up to 5 component names similar to the given name.

func (*Library) Get

func (l *Library) Get(name string) (string, error)

Get retrieves the source code for a component by name.

func (*Library) GetEntry

func (l *Library) GetEntry(name string) (*Entry, bool)

GetEntry retrieves the metadata entry for a component by name.

func (*Library) List

func (l *Library) List(tag, category string) []Entry

List returns all components, optionally filtered by tag and/or category.

func (*Library) Registry

func (l *Library) Registry() []Entry

Registry returns all component entries.

func (*Library) Search

func (l *Library) Search(query string) []Entry

Search finds components using unified keyword search. See SearchDetailed for the semantics; this is the entries-only convenience wrapper.

func (*Library) SearchDetailed

func (l *Library) SearchDetailed(query string) (entries []Entry, matched, total int)

SearchDetailed finds components by keyword and reports how much of the query it was able to honour. The query is split into words; each word is matched against the component's name, tags, category, and description.

Semantics are BEST-MATCH, not bag-of-words AND. A component's match count is how many query words it hits; the result set is every component whose count equals the BEST count any component achieved, ordered by a field-weighted score (name > tag > category > description).

Why not AND: a search that gets WORSE as you describe your need more precisely is backwards, and that is exactly what AND does. `dashboard metric stat tiles` returned nothing while `dashboard metric stat` returned metric_card — one extra, more specific word emptied the library. Under best-match, adding a word that nothing carries cannot destroy a result set; it can only re-rank one. Everything a caller could want is preserved:

  • one word — identical to the old behaviour;
  • all words matched by something — identical to AND (best == len(words));
  • nothing matched at all — still empty, so "no such component" is still distinguishable from "here is the closest thing".

Returns (entries, matched, total): `total` is the number of query words, `matched` the number the returned entries actually hit. matched < total is the caller's cue to say so rather than present a partial hit as exact.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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