toml

package
v0.4.5 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: MIT Imports: 4 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnyMap

func AnyMap(value any) map[string]any

AnyMap returns value as a TOML table, or nil when it is not one

func AnySlice

func AnySlice(value any) ([]any, bool)

AnySlice coerces common TOML slice types to []any

func BoolPtr

func BoolPtr(value any) *bool

BoolPtr converts a TOML any value to *bool, returning nil for non-bool

func Decode

func Decode(text string, target any) error

Decode decodes TOML text into target, discarding the decoder metadata

func DecodeFile

func DecodeFile(path string, target any) error

DecodeFile decodes the TOML file at path into target

func Encode

func Encode(value any) (string, error)

Encode renders value as TOML text

func IntPtr

func IntPtr(value any) *int

IntPtr converts a TOML any value to *int, returning nil for non-int

func IntValue

func IntValue(m map[string]any, key string, fallback int) int

IntValue returns the int at key, falling back when the key is missing or holds another type

func LoadMerged

func LoadMerged(paths []string, depth int) (map[string]any, bool)

LoadMerged overlays each readable path onto the previous ones

func LoadMergedWithBase

func LoadMergedWithBase(
	base map[string]any, paths []string, depth int,
) (map[string]any, bool)

LoadMergedWithBase merges TOML files onto an already decoded base map

func MergeValues

func MergeValues(values Overlay[any], depth int) any

MergeValues overlays Over onto Base, merging maps only while depth remains. Below that Over replaces Base outright

func StringMap

func StringMap(value any) map[string]string

StringMap keeps the string-valued entries of a TOML table, dropping the rest

func StringOrSlice

func StringOrSlice(value any) []string

StringOrSlice accepts either a bare string or a slice of them

func StringPtr

func StringPtr(value any) *string

StringPtr converts a TOML any value to *string, returning nil for non-string

func StringSlice

func StringSlice(value any) []string

StringSlice keeps the string elements of a TOML slice, dropping the rest

func StringValue

func StringValue(m map[string]any, key string) string

StringValue returns the string at key, or the empty string when the key is missing or holds another type

Types

type Overlay

type Overlay[T any] struct {
	Base T
	Over T
}

Overlay is a base value and the value layered on top of it

Jump to

Keyboard shortcuts

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