go-toml – github.com/pelletier/go-toml Index | Files | Directories

package toml

import "github.com/pelletier/go-toml"

TOML markup language parser.

This version supports the specification as described in https://github.com/toml-lang/toml/blob/master/versions/toml-v0.2.0.md

Index

Types

type TomlTree

type TomlTree map[string]interface{}

Definition of a TomlTree. This is the result of the parsing of a TOML file.

func Load

func Load(content string) (tree *TomlTree, err error)

Create a TomlTree from a string.

func LoadFile

func LoadFile(path string) (tree *TomlTree, err error)

Create a TomlTree from a file.

func (*TomlTree) Get

func (t *TomlTree) Get(key string) interface{}

Get the value at key in the TomlTree. Key is a dot-separated path (e.g. a.b.c). Returns nil if the path does not exist in the tree. If keys is of length zero, the current tree is returned.

func (*TomlTree) GetDefault

func (t *TomlTree) GetDefault(key string, def interface{}) interface{}

Same as Get but with a default value

func (*TomlTree) GetPath

func (t *TomlTree) GetPath(keys []string) interface{}

Returns the element in the tree indicated by 'keys'. If keys is of length zero, the current tree is returned.

func (*TomlTree) Has

func (t *TomlTree) Has(key string) bool

Has returns a boolean indicating if the toplevel tree contains the given key.

func (*TomlTree) Keys

func (t *TomlTree) Keys() []string

Keys returns the keys of the toplevel tree. Warning: this is a costly operation.

func (*TomlTree) Set

func (t *TomlTree) Set(key string, value interface{})

Set an element in the tree. Key is a dot-separated path (e.g. a.b.c). Creates all necessary intermediates trees, if needed.

func (*TomlTree) SetPath

func (t *TomlTree) SetPath(keys []string, value interface{})

func (*TomlTree) ToString

func (t *TomlTree) ToString() string

Generates a human-readable representation of the current tree. Output spans multiple lines, and is suitable for ingest by a TOML parser

Source Files

lexer.go parser.go toml.go

Directories

PathSynopsis
cmd
Version
v0.2.0
Published
Jul 9, 2014
Platform
linux/amd64
Imports
11 packages
Last checked
10 minutes ago

Tools for package owners.