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

toml

package
v1.10.16 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatValue

func FormatValue(value any) ([]byte, error)

FormatValue returns a TOML-encoded scalar value.

func FormatValueString

func FormatValueString(value any) string

FormatValueString returns a TOML-encoded scalar value as a string.

func SetValuesInBytes

func SetValuesInBytes(inBytes []byte, updates []Update) ([]byte, error)

SetValuesInBytes returns a copy of the provided bytes with the changes specified by Updates applied. Keys are of the form <key 0>.<key 1>...<key n>. Integers may be used as keys where a specific array element needs to be selected. An error is returned for any attempted update to a key that does not exist or does not address a scalar node. Untouched bytes are preserved.

func SetValuesInFile

func SetValuesInFile(file string, updates []Update) error

SetValuesInFile overwrites the specified file with the changes specified by the list of Updates. Keys are of the form <key 0>.<key 1>...<key n>. Integers may be used as keys where a specific array element needs to be selected. An error is returned for any attempted update to a key that does not exist or does not address a scalar node. Untouched bytes are preserved.

Types

type Update

type Update struct {
	// Key is the dot-separated path to the field to update.
	Key string
	// Value is the new value to set for the field.
	Value any
}

Update represents a discrete update to be made to a TOML document.

Jump to

Keyboard shortcuts

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