Documentation
¶
Overview ¶
Package datatable is experimental: its API and documented formats may change in a minor release; see https://nsgo.games/docs/stability/.
Package datatable loads typed game data tables (enemies, items, levels, quests) from CSV, JSON, and YAML with rich per-cell error reporting and live hot reload.
YAML is the table format this repository defines: a mapping with a version field (FormatVersion) and a rows list, in which every key of a row names a field of the row type. Unknown fields, duplicate fields, missing or unsupported versions are refused. MarshalYAML and SaveYAML write the same format deterministically (fields in struct order, two-space indentation), so a table loaded and saved again is unchanged. CSV and JSON tables are read as their tools export them.
Index ¶
- Constants
- Variables
- func EnvelopeSchema(opts jsonschema.Options) (*jsonschema.Schema, error)
- func LoadCSV[T any](filename string, data []byte) ([]T, error)
- func LoadFile[T any](path string) ([]T, error)
- func LoadJSON[T any](filename string, data []byte) ([]T, error)
- func LoadYAML[T any](filename string, data []byte) ([]T, error)
- func Lookup[T any, K comparable](s *Snapshot, name string, key K) (T, bool)
- func MarshalYAML[T any](rows []T) ([]byte, error)
- func MarshalYAMLSide[T any](rows []T, side Side) ([]byte, error)
- func MatchPattern(pattern, filePath string) (bool, error)
- func RegisterNamedRowType[T any](r *Registry, name, pattern string) error
- func RegisterRowType[T any](r *Registry, pattern string) error
- func RegisterTable[T any](s *Set, name, path string) error
- func Rows[T any](s *Snapshot, name string) []T
- func SaveYAML[T any](path string, rows []T) error
- func SaveYAMLSide[T any](path string, rows []T, side Side) error
- func Schema[T any](opts jsonschema.Options) (*jsonschema.Schema, error)
- type Cell
- type CellChange
- type CellError
- type ColumnSpec
- type Document
- func (d *Document) AddRow(index int, cells ...Cell) error
- func (d *Document) AppendRow(cells ...Cell) (int, error)
- func (d *Document) Cell(row int, col string) (Value, bool)
- func (d *Document) CellLine(row int, col string) int
- func (d *Document) Clone() *Document
- func (d *Document) ColumnKind(col string) ValueKind
- func (d *Document) Columns() []string
- func (d *Document) DeleteCell(row int, col string) error
- func (d *Document) DeleteRow(index int) error
- func (d *Document) FilterSide(rt *RowType, side Side) (*Document, error)
- func (d *Document) Marshal() ([]byte, error)
- func (d *Document) MarshalSide(rt *RowType, side Side) ([]byte, error)
- func (d *Document) MoveRow(from, to int) error
- func (d *Document) Row(index int) Row
- func (d *Document) RowCount() int
- func (d *Document) RowLine(row int) int
- func (d *Document) Rows() []Row
- func (d *Document) Save(path string) error
- func (d *Document) SetCell(row int, col string, val Value) error
- func (d *Document) Version() int
- type Problem
- type Registry
- func (r *Registry) CheckFS(fsys fs.FS) []Problem
- func (r *Registry) Clone() *Registry
- func (r *Registry) Lookup(pattern string) (*RowType, bool)
- func (r *Registry) Match(filePath string) *RowType
- func (r *Registry) Register(pattern string, rt *RowType) error
- func (r *Registry) RegisterNamed(name, pattern string, rt *RowType) error
- func (r *Registry) TableName(filePath string) string
- type Row
- type RowChange
- type RowChangeKind
- type RowType
- func (rt *RowType) Column(col string) (ColumnSpec, bool)
- func (rt *RowType) Columns() []ColumnSpec
- func (rt *RowType) ColumnsForSide(side Side) []ColumnSpec
- func (rt *RowType) KeyColumn() (ColumnSpec, bool)
- func (rt *RowType) Name() string
- func (rt *RowType) ParseCellText(filename string, row int, field, raw string) (Value, error)
- func (rt *RowType) RefColumns() []ColumnSpec
- func (rt *RowType) TextKeyColumns() []ColumnSpec
- func (rt *RowType) Type() reflect.Type
- func (rt *RowType) ValidateCell(filename string, row int, field string, val Value) error
- func (rt *RowType) ValidateDocument(filename string, doc *Document) error
- func (rt *RowType) ValidateRow(filename string, row int, r Row) error
- type Set
- type Side
- type Snapshot
- type Table
- type Value
- func BoolValue(b bool) Value
- func DurationValue(d time.Duration) Value
- func ExprValue(s string) Value
- func FloatValue(f float64) Value
- func InferValue(raw string) Value
- func IntValue(n int64) Value
- func ListValue(items ...Value) Value
- func MapValue(entries ...Cell) Value
- func NullValue() Value
- func ParseValue(kind ValueKind, raw string) (Value, error)
- func StringValue(s string) Value
- func UintValue(n uint64) Value
- func ZeroValue(kind ValueKind) Value
- type ValueKind
- type View
Examples ¶
Constants ¶
const FormatVersion = 1
FormatVersion is the schema version of a YAML data table: LoadYAML accepts only this version and MarshalYAML writes it.
const SchemaComment = "# yaml-language-server: $schema=" + SchemaURL
SchemaComment is the first line MarshalYAML writes: a YAML comment that points a YAML language server at SchemaURL. LoadYAML ignores it like any other comment.
const SchemaURL = "https://nsgo.games/schemas/datatable.v1.json"
SchemaURL is where the JSON Schema of the YAML data table envelope is published. MarshalYAML names it in a yaml-language-server comment on a table's first line, so editors and AI tools validate and complete the document as it is written.
Variables ¶
var ErrConstraint = errors.New("constraint violation")
ErrConstraint is the error a CellError wraps when a cell or row violates a `schema` struct tag constraint such as required, const, enum, minimum, maximum, exclusiveMinimum, exclusiveMaximum, minLength, minItems, or maxItems.
var ErrDanglingReference = errors.New("unknown referenced key")
ErrDanglingReference is the error a CellError wraps when a referenced key is missing from the candidate snapshot.
var ErrDuplicateField = errors.New("duplicate field")
ErrDuplicateField is the error a CellError wraps when a YAML row sets the same field twice, for example as "hp" and "HP".
var ErrDuplicateKey = errors.New("duplicate primary key")
ErrDuplicateKey is the error a CellError wraps when two rows share a primary key.
var ErrUnknownField = errors.New("unknown field")
ErrUnknownField is the error a CellError wraps when a YAML row has a key that names no field of the row type.
Functions ¶
func EnvelopeSchema ¶
func EnvelopeSchema(opts jsonschema.Options) (*jsonschema.Schema, error)
EnvelopeSchema returns the draft-07 JSON Schema of the YAML data table envelope, which MarshalYAML writes and LoadYAML reads: a mapping with a required version, which must equal FormatVersion, and rows, a list of mappings whose keys are a row type's columns, or null for a table with no rows; any other top-level key is refused.
A table's columns come from the game's row type, which the envelope cannot know, so each row is an object with any keys. Schema[T] builds a schema that also checks and describes the columns of T's rows; a game writes one per table and names it in the file's first line in place of SchemaURL.
func LoadCSV ¶
LoadCSV parses UTF-8 CSV data with a header row into []T. Slice fields in CSV cells may be delimited by ';', '|', or ','.
func LoadFile ¶
LoadFile reads path from disk and decodes it into []T based on its file extension (.csv, .json, .yaml, or .yml).
func LoadYAML ¶
LoadYAML parses a versioned YAML data table into []T. Its errors about the document are *loaderr.Error values that name filename, the line and a fix; one about a cell wraps the *CellError.
The document is a mapping with two keys: version, which must equal FormatVersion, and rows, a list of mappings whose keys name fields of T by their table tag, json tag or Go field name (matched exactly first, then case-insensitively). A missing or empty rows key is an empty table. Struct fields (named or inline) decode from nested mappings with the same tag, unknown-field, duplicate-field, and `schema` constraint rules; maps take string or encoding.TextUnmarshaler keys and refuse duplicate keys; slices of structs or maps decode from YAML sequences. Any other top-level key, a missing or unsupported version, a key that names no field (ErrUnknownField), a field or map key set twice (ErrDuplicateField), and any `schema` struct tag constraint violation (ErrConstraint) are refused, as are a merge key (<<), a second YAML document in the same file, and a struct type in which two fields share a column name; errors inside a row are a *CellError naming the 1-based row and the field or nested path (such as rewards[1].count). Fields whose type implements encoding.TextUnmarshaler decode through UnmarshalText.
Example ¶
LoadYAML reads a data table, a mapping with version: 1 and a list of rows with one field per column, into a slice of structs.
package main
import (
"fmt"
"time"
"github.com/nsgo-dev/game/pkg/datatable"
)
type weapon struct {
ID string `table:"id"`
Damage int `table:"damage"`
Cooldown time.Duration `table:"cooldown"`
Tags []string `table:"tags"`
}
func main() {
rows, err := datatable.LoadYAML[weapon]("weapons.yaml", []byte(`version: 1
rows:
- id: sword
damage: 12
cooldown: 400ms
tags: [melee]
- id: bow
damage: 8
cooldown: 1s
tags: [ranged, two-handed]
`))
if err != nil {
fmt.Println(err)
return
}
for _, w := range rows {
fmt.Println(w.ID, w.Damage, w.Cooldown, w.Tags)
}
}
Output: sword 12 400ms [melee] bow 8 1s [ranged two-handed]
func Lookup ¶
func Lookup[T any, K comparable](s *Snapshot, name string, key K) (T, bool)
Lookup returns the indexed row from name in this generation. K must be the primary key column's Go type. Treat any nested row data as read-only.
func MarshalYAML ¶
MarshalYAML encodes rows as a versioned YAML data table that LoadYAML reads back, SchemaComment on its first line.
The output is deterministic: SchemaComment, version, then rows, each row writing every field of T in struct declaration order under its table tag, json tag or Go field name, with two-space indentation. Flat scalar lists are written inline ([a, b]), lists of structs, maps or nested lists are written in block style, structs and maps (with string or encoding.TextMarshaler keys sorted) are written inline when they fit on one line and in block style otherwise, a nil pointer as null, a time.Duration as its String form (such as 1.5s), and a value implementing encoding.TextMarshaler through MarshalText. A nil or empty list is written as [], and a nil or empty map as {}, which load back as empty. Non-finite floats, unsupported field types (interfaces, channels, functions, maps with non-text keys) and a struct type in which two fields share a column name are an error.
func MarshalYAMLSide ¶
MarshalYAMLSide encodes rows as a canonical versioned YAML data table containing only the columns read by side, in struct declaration order.
When side is Both, every column is written (matching MarshalYAML). When side is Client, columns tagged `server` are omitted; when side is Server, columns tagged `client` are omitted. The output is deterministic `version: 1` YAML that LoadYAML[T] loads back with any stripped columns left at their zero values.
func MatchPattern ¶
MatchPattern reports whether filePath matches pattern. Both paths are normalized to forward slashes with leading "./" removed. A pattern with no '/' matches path.Base(filePath). A "**" path segment matches zero or more segments.
func RegisterNamedRowType ¶
RegisterNamedRowType registers Go struct row type T for files matching pattern under logical table name. Cross-table references (`ref=<name>`) in Registry.CheckFS and the editor resolve to this binding.
func RegisterRowType ¶
RegisterRowType registers Go struct row type T for files matching pattern in r.
func RegisterTable ¶
RegisterTable adds a file and its row type under name for the next Reload.
func Rows ¶
Rows returns the shared slice for name, or nil if the table has a different row type or is absent. Treat the slice, its rows and any nested values as read-only. A later reload leaves the slice reachable through this snapshot.
func SaveYAML ¶
SaveYAML writes rows to path as a versioned YAML data table in the form MarshalYAML produces.
func SaveYAMLSide ¶
SaveYAMLSide writes rows to path as a canonical versioned YAML data table containing only the columns read by side.
func Schema ¶
func Schema[T any](opts jsonschema.Options) (*jsonschema.Schema, error)
Schema returns the JSON Schema of a YAML data table of T rows, the format LoadYAML reads and MarshalYAML writes, for an editor or AI tool to validate and complete a table file while it is written.
The schema is a mapping with a required version, which must equal FormatVersion, and rows, a list of T's rows that may be left out or null for a table with no rows; any other top-level key is refused. Each row is an object keyed by the column names LoadYAML matches, from a field's `table` tag, else its `json` tag, else its Go name, spelled as MarshalYAML writes them, with embedded structs that have neither tag merged in, as the loaders do. A row type in which two fields share a column name is an error, as it is for LoadYAML. A time.Duration is a string such as "1.5s" or an integer of nanoseconds, and a field whose type implements encoding.TextMarshaler or encoding.TextUnmarshaler is a string. Constraints declared in `schema` struct tags are emitted in the schema and enforced by the loaders through the same jsonschema.ParseTag parser.
The schema describes a table's canonical spelling, which is as strict as LoadYAML about unknown columns and stricter about the rest: it refuses other capitalizations of a column name (LoadYAML also matches a column name in another case), and wants each cell as its own type rather than a string LoadYAML would convert, and a list as a YAML sequence rather than a delimited string. LoadYAML also refuses merge keys (<<), which a YAML language server resolves before validating, so the schema cannot flag them.
opts sets the $id, title and descriptions; Schema fills in FieldName and the time.Duration form unless opts sets them, so a game can pass sourcedocs.PackageDocs (pkg/jsonschema/sourcedocs) of its own package as opts.Docs to describe each column. The row schema is at #/definitions/<T's name>.
Types ¶
type CellChange ¶
type CellChange struct {
// Column is the column's key as it is written in the row.
Column string
// Before is the cell's value in the first document in display form, or nil when the row or column is absent there.
Before *string
// After is the cell's value in the second document in display form, or nil when the row or column is absent there.
After *string
}
CellChange is one column of a row that differs between two data table documents.
type CellError ¶
CellError identifies the exact file, 1-based data row, and column/field name where parsing or type conversion failed.
The loaders return it inside a *loaderr.Error, which adds the cell's line and column in the file and a fix; errors.As finds either.
Example ¶
A bad cell is reported as a CellError naming the file, row and field, so a designer can find it.
package main
import (
"errors"
"fmt"
"time"
"github.com/nsgo-dev/game/pkg/datatable"
)
type weapon struct {
ID string `table:"id"`
Damage int `table:"damage"`
Cooldown time.Duration `table:"cooldown"`
Tags []string `table:"tags"`
}
func main() {
_, err := datatable.LoadCSV[weapon]("weapons.csv", []byte("id,damage,cooldown,tags\nsword,twelve,400ms,melee\n"))
var cell *datatable.CellError
if errors.As(err, &cell) {
fmt.Println(cell.File, cell.Row, cell.Field, cell.Value)
}
}
Output: weapons.csv 1 damage twelve
type ColumnSpec ¶
type ColumnSpec struct {
Name string
Kind ValueKind
ElemKind ValueKind
Nullable bool
Type reflect.Type
Key bool
Ref string
TextKey bool
Side Side
}
ColumnSpec describes one column of a Go struct row type.
type Document ¶
type Document struct {
// contains filtered or unexported fields
}
Document is an untyped, round-trip editable YAML data table.
Each row keeps its own key order. Opening a table and calling Marshal without edits returns the exact input bytes; editing a single scalar or inline-list cell changes only that cell's line; structural edits (adding, deleting, or reordering rows, or adding a new key to a row) encode deterministically from the preserved YAML AST so untouched rows keep their key order, formatting, and comments.
func LoadDocument ¶
LoadDocument reads path from disk and parses it as an untyped YAML data table.
func NewDocument ¶
func NewDocument() *Document
NewDocument constructs an empty version 1 YAML data table document.
func ParseDocument ¶
ParseDocument parses a versioned YAML data table into an untyped Document. It enforces the same envelope rules as LoadYAML (version: 1, no unknown top-level keys, no merge keys, no duplicate keys, no trailing second document) without requiring a Go row type.
func (*Document) AddRow ¶
AddRow inserts a new row at index (0 <= index <= RowCount()) with the given ordered cells.
func (*Document) AppendRow ¶
AppendRow appends a new row at the end of d and returns its 0-based index.
func (*Document) CellLine ¶
CellLine returns the 1-based YAML line number of column col (or nested path such as "rewards[1].count") in row, or 0 if the cell or its line metadata is unavailable.
func (*Document) Clone ¶
Clone returns a deep copy of d, including its preserved bytes and YAML AST.
func (*Document) ColumnKind ¶
ColumnKind infers the ValueKind of col from the non-null values present in d. It returns KindNull if no row has a non-null value for col, the shared kind if all non-null values agree, or KindString if values have mixed kinds.
func (*Document) Columns ¶
Columns returns the union of all rows' keys in deterministic first-appearance order.
func (*Document) DeleteCell ¶
DeleteCell removes col from row if present.
func (*Document) FilterSide ¶
FilterSide validates d against rt and returns a new canonical Document containing only the columns (and nested struct fields) read by side, in rt's struct declaration order under their canonical column names. Comments and fields not read by side are omitted, and optional fields absent from a row or nested struct stay omitted.
func (*Document) Marshal ¶
Marshal encodes d back to YAML. If no edits have invalidated the preserved bytes, Marshal returns the exact preserved bytes (unchanged for an unedited file, or patched on only the edited lines); otherwise it encodes deterministically from the AST with two-space indentation.
func (*Document) MarshalSide ¶
MarshalSide filters d for side through rt and encodes the result as canonical, deterministic `version: 1` YAML with columns in rt's struct declaration order and SchemaComment on its first line, byte for byte what MarshalYAMLSide writes for the same rows.
func (*Document) MoveRow ¶
MoveRow moves the row at index from to index to, preserving its key order, comments, and formatting.
func (*Document) RowLine ¶
RowLine returns the 1-based YAML line number where row begins in the parsed document, or 0 if line metadata is unavailable (for example on a newly added row).
type Problem ¶
type Problem struct {
// File is the slash-separated path relative to the checked filesystem root.
File string
// Line and Column are 1-based, or zero if the location is unknown.
Line, Column int
// Message describes the problem without the file position.
Message string
}
Problem describes a file read or validation error from Registry.CheckFS.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry maps slash-separated file patterns (or basename patterns without '/') to Go row types so editors and tools can validate untyped YAML data tables with LoadYAML's rules.
func (*Registry) CheckFS ¶
CheckFS checks the .yaml and .yml data tables matched by r, returning problems in filesystem walk order. It validates each file against its matched RowType, checks cross-table `ref=<table>` columns across all matched tables using each table's registered name (or filename stem), and checks every non-empty `textkey` column cell against every localization string table locale in the same project. It reports the first parse/type/ref problem per matching file, every missing localization key per locale when a table otherwise validates, and any errors walking fsys. It skips directories whose names start with a dot or an underscore, and directories named testdata. A nil or empty registry does no work.
func (*Registry) Lookup ¶
Lookup returns the RowType registered for pattern (after path normalization) and reports whether pattern is registered.
func (*Registry) Match ¶
Match returns the first registered RowType whose pattern matches filePath, or nil.
func (*Registry) Register ¶
Register binds pattern to rt. If pattern is already registered, its binding is replaced. Patterns are matched in registration order; a pattern without '/' matches the file's basename, and "**" matches zero or more path segments.
func (*Registry) RegisterNamed ¶
RegisterNamed binds pattern to rt under logical table name so cross-table `ref=<name>` checks and editor pickers resolve matched files to name regardless of their file stem.
type Row ¶
type Row struct {
Cells []Cell
}
Row is an ordered mapping of column keys to cell values, preserving the YAML key order.
type RowChange ¶
type RowChange struct {
// Key is the row's identity: the value of its "id", "ID", "key" or "name" column, else of its first column, else "row_N" for its 1-based position. A repeated key is suffixed with "#2", "#3" and so on in document order.
Key string
// Kind says whether the row was added, removed or changed.
Kind RowChangeKind
// Cells are the changed cells: removed and changed cells in the first document's row order, then added cells in the second document's row order. It is nil for added and removed rows, whose contents appear in Before and After.
Cells []CellChange
// Before is a copy of the row in the first document, or nil when it was added.
Before *Row
// After is a copy of the row in the second document, or nil when it was removed.
After *Row
}
RowChange is one row a data table added, removed or changed, with the cells that differ.
func DiffDocuments ¶
DiffDocuments compares two untyped YAML data table documents row by row. Rows are matched by their identity column, as RowChange.Key describes, so changing a non-key column reports one changed row, while changing the identity itself reports one removed and one added row. It returns the removed and changed rows in the first document's order, followed by the added rows in the second document's order, so the same two documents always give the same list. A nil document has no rows.
type RowChangeKind ¶
type RowChangeKind uint8
RowChangeKind identifies how a row changed between two data table documents.
const ( // RowAdded is a row only the second document has. RowAdded RowChangeKind = iota // RowRemoved is a row only the first document has. RowRemoved // RowChanged is a row both documents have whose cells differ. RowChanged )
type RowType ¶
type RowType struct {
// contains filtered or unexported fields
}
RowType describes a Go struct row type so an untyped Document or editor grid can validate cells and rows with the exact same rules LoadYAML applies.
func RowTypeFor ¶
RowTypeFor builds a RowType for Go struct type T. It applies the same structural checks as LoadYAML[T] (must be a struct with no two fields sharing a column name).
func (*RowType) Column ¶
func (rt *RowType) Column(col string) (ColumnSpec, bool)
Column looks up col by exact name first and then case-insensitively, as LoadYAML does.
func (*RowType) Columns ¶
func (rt *RowType) Columns() []ColumnSpec
Columns returns the row type's columns in struct declaration order.
func (*RowType) ColumnsForSide ¶
func (rt *RowType) ColumnsForSide(side Side) []ColumnSpec
ColumnsForSide returns the columns read by side in struct declaration order.
func (*RowType) KeyColumn ¶
func (rt *RowType) KeyColumn() (ColumnSpec, bool)
KeyColumn returns the primary key column declared with `,key`, if any.
func (*RowType) ParseCellText ¶
ParseCellText parses raw grid text for field according to rt and validates it with LoadYAML's rules, returning the typed Value or a *CellError.
func (*RowType) RefColumns ¶
func (rt *RowType) RefColumns() []ColumnSpec
RefColumns returns the columns declared with `,ref=<table>` in struct declaration order.
func (*RowType) TextKeyColumns ¶
func (rt *RowType) TextKeyColumns() []ColumnSpec
TextKeyColumns returns the columns declared with `,textkey` in struct declaration order.
func (*RowType) ValidateCell ¶
ValidateCell validates a single cell value against rt using LoadYAML's conversion and `schema` tag constraint rules. row is 0-based; CellError reports 1-based Row.
func (*RowType) ValidateDocument ¶
ValidateDocument validates every row of doc and checks primary key uniqueness.
type Set ¶
type Set struct {
// contains filtered or unexported fields
}
Set publishes named, typed tables together. Its zero value is an empty set. A Set must not be copied after first use.
func NewSet ¶
NewSet creates an empty set. If validate is given, it checks a candidate snapshot before publication. It can read both the candidate and Current, but must not register tables or call Reload on the same set.
type Side ¶
type Side uint8
Side identifies which side of a game reads a data table column. The zero value (Both) means both client and server read the column.
type Snapshot ¶
type Snapshot struct {
// contains filtered or unexported fields
}
Snapshot holds the rows of a Set from one successful reload.
type Table ¶
type Table[T any] struct { // contains filtered or unexported fields }
Table holds a typed game data table loaded from disk. datatablewatch adds hot reloading via tooling/hotreload for game clients; headless builds such as a dedicated server load tables without it.
If a reload fails (for example due to a typo in a cell during editing), Table preserves the last valid rows and records the error in LastError.
func (*Table[T]) Get ¶
Get returns the current row with key. Use View.Get when several reads must use the same load generation.
func (*Table[T]) LastError ¶
LastError returns the error from the most recent reload attempt, or nil if it succeeded.
func (*Table[T]) Reload ¶
Reload re-reads the file from disk. On success, it atomically replaces Rows and increments Version. On failure, existing Rows are preserved and LastError is updated.
func (*Table[T]) ReloadBytes ¶
ReloadBytes parses raw file bytes using the table's file extension. On success, it atomically replaces Rows and increments Version.
func (*Table[T]) Rows ¶
func (t *Table[T]) Rows() []T
Rows returns a copy of the currently loaded rows.
type Value ¶
Value holds a single cell's value in an untyped YAML data table.
Scalar values keep their exact text representation in Text (so large int64/uint64 values and integer-vs-float distinctions survive round-trips without float64 precision loss); KindList values store their elements in List; KindMap values store their ordered key-value entries in Map.
func DurationValue ¶
DurationValue returns a KindDuration Value formatted with time.Duration.String.
func FloatValue ¶
FloatValue returns a KindNumber Value holding a float64.
func InferValue ¶
InferValue infers a Value and its ValueKind from raw user text.
func ParseValue ¶
ParseValue parses raw user text as a Value of kind.
type ValueKind ¶
type ValueKind int
ValueKind classifies a cell value in an untyped YAML data table.
type View ¶
type View[T any] struct { // contains filtered or unexported fields }
View is an immutable, zero-copy read view of a Table at one version. Callers must not modify Rows. A later reload publishes a new view and does not change an existing View.
func (View[T]) Get ¶
Get returns the row with key. The key must have the primary key field's Go type. Mutable values referenced by the returned row are shared with the view.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package datatablewatch is experimental: its API and documented formats may change in a minor release; see https://nsgo.games/docs/stability/.
|
Package datatablewatch is experimental: its API and documented formats may change in a minor release; see https://nsgo.games/docs/stability/. |