topicyaml

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: MIT Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package topicyaml edits a topic's topic.yaml at the yaml.Node level so every key, comment and key order that the caller does not touch survives a write. Both internal/topic (metadata) and internal/contract (contract, drafts, decisions block) write through it.

Index

Constants

View Source
const FileName = "topic.yaml"

FileName is the topic metadata file name.

Variables

This section is empty.

Functions

func Delete

func Delete(mapping *yaml.Node, key string) bool

Delete removes key from mapping and reports whether it was present.

func Get

func Get(mapping *yaml.Node, key string) *yaml.Node

Get returns the value node for key in mapping, or nil.

func Mapping

func Mapping(mapping *yaml.Node, key string) (*yaml.Node, error)

Mapping returns the mapping stored under key, creating an empty one when the key is missing or null. A non-mapping value is an error.

func Set

func Set(mapping *yaml.Node, key string, value any) error

Set encodes value and stores it under key, replacing the existing value in place (the key node and its comments are kept) or appending the key.

func SetNode

func SetNode(mapping *yaml.Node, key string, node *yaml.Node)

SetNode stores node under key, replacing in place or appending.

func Update

func Update(path string, edit func(root *yaml.Node) error) error

Update loads path, applies edit and saves the result atomically.

func WriteFileAtomic

func WriteFileAtomic(path string, content []byte) error

WriteFileAtomic writes content to a temporary file next to path and renames it into place, keeping the existing file mode (0644 for new files).

Types

type Document

type Document struct {
	// contains filtered or unexported fields
}

Document is a parsed topic.yaml whose root is always a mapping node.

func Load

func Load(path string) (*Document, error)

Load reads path into a Document. A missing or empty file yields an empty mapping. A file whose root is not a mapping is an error.

func Parse

func Parse(content []byte) (*Document, error)

Parse decodes content into a Document.

func (*Document) Bytes

func (d *Document) Bytes() ([]byte, error)

Bytes encodes the document with two-space indentation.

func (*Document) Root

func (d *Document) Root() *yaml.Node

Root returns the top-level mapping node.

func (*Document) Save

func (d *Document) Save(path string) error

Save encodes the document and writes it to path atomically.

Jump to

Keyboard shortcuts

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