fml

package module
v0.0.0-...-0c0fd08 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2019 License: MIT Imports: 14 Imported by: 4

README

FML

FML FIPress Markup Language, used for config files, simple to understand.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Delimiter byte = '='
)

Functions

func IterateFimlDoc

func IterateFimlDoc(doc *FML)

for test

func Unmarshal

func Unmarshal(data []byte, v interface{}) (err error)

func UnmarshalFile

func UnmarshalFile(path string, v interface{}) (err error)

func UnmarshalString

func UnmarshalString(input string, v interface{}) (err error)

Types

type FML

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

A FML represents a fml node

func Load

func Load(path string) (doc *FML, err error)

func NewFml

func NewFml() *FML

NewFml creates an empty node

func Parse

func Parse(input []byte) (doc *FML, err error)

func ParseString

func ParseString(input string) (doc *FML, err error)

func (*FML) GetArrayOrError

func (f *FML) GetArrayOrError(key string) (array interface{}, err error)

GetArrayOrError gets an array from the node.

func (*FML) GetBool

func (f *FML) GetBool(key string) (val bool)

GetBoolOrZero gets a bool value from the node, or return zero value of bool, false, if the key does not exist or other error happens.

func (*FML) GetBoolArray

func (f *FML) GetBoolArray(key string) []bool

GetBoolArray gets an array of bool from the node. It returns nil if the key does not exist or other error happens.

func (*FML) GetBoolArrayOrError

func (f *FML) GetBoolArrayOrError(key string) (arr []bool, err error)

GetBoolArrayOrError gets an array of bool from the node.

func (*FML) GetBoolOrDefault

func (f *FML) GetBoolOrDefault(key string, defaultVal bool) bool

GetBoolOrDefault gets a bool value from the node, or return defaultVal, if the key does not exist or other error happens.

func (*FML) GetBoolOrError

func (f *FML) GetBoolOrError(key string) (val bool, err error)

GetBoolOrError gets a bool value from the node.

func (*FML) GetDatetime

func (f *FML) GetDatetime(key string) (val time.Time)

GetDatetime gets a time.Time value from the node, or return zero value of Datetime, time.Time{}, if the key does not exist or other error happens.

func (*FML) GetDatetimeOrDefault

func (f *FML) GetDatetimeOrDefault(key string, defaultVal time.Time) time.Time

GetDatetimeOrDefault gets a time.Time value from the node, or return defaultVal, if the key does not exist or other error happens.

func (*FML) GetFloat

func (f *FML) GetFloat(key string) (val float64)

GetFloat gets a float value from the node, or return zero value of int, 0, if the key does not exist or other error happens.

func (*FML) GetFloatArray

func (f *FML) GetFloatArray(key string) []float64

GetFloatArray gets an array of float from the node. It returns nil if the key does not exist or other error happens.

func (*FML) GetFloatArrayOrError

func (f *FML) GetFloatArrayOrError(key string) (arr []float64, err error)

GetFloatArrayOrError gets an array of float from the node.

func (*FML) GetFloatOrDefault

func (f *FML) GetFloatOrDefault(key string, defaultVal float64) float64

GetFloatOrDefault gets a float value from the node, or return defaultVal, if the key does not exist or other error happens.

func (*FML) GetFloatOrError

func (f *FML) GetFloatOrError(key string) (val float64, err error)

GetFloatOrError gets a float value from the node.

func (*FML) GetInt

func (f *FML) GetInt(key string) (val int)

GetIntOrZero gets a int value from the node, or return zero value of int, 0, if the key does not exist or other error happens.

func (*FML) GetIntArray

func (f *FML) GetIntArray(key string) []int

GetIntArray gets an array of int from the node. It returns nil if the key does not exist or other error happens.

func (*FML) GetIntArrayOrError

func (f *FML) GetIntArrayOrError(key string) (arr []int, err error)

GetIntArrayOrError gets an array of int from the node.

func (*FML) GetIntOrDefault

func (f *FML) GetIntOrDefault(key string, defaultVal int) int

GetIntOrDefault gets a int value from the node, or return defaultVal, if the key does not exist or other error happens.

func (*FML) GetIntOrError

func (f *FML) GetIntOrError(key string) (val int, err error)

GetIntOrError gets a int value from the node.

func (*FML) GetNode

func (f *FML) GetNode(key string) (node *FML, err error)

GetNode gets a sub-node from the node

func (*FML) GetNodeList

func (f *FML) GetNodeList(key string) (list []*FML, err error)

GetNodeList gets a node list from the node

func (*FML) GetString

func (f *FML) GetString(key string) (val string)

GetString gets a string value from the node, or return zero value of string, "", if the key does not exist or other error happens.

func (*FML) GetStringArray

func (f *FML) GetStringArray(key string) []string

GetStringArray gets an array of string from the node. It returns nil if the key does not exist or other error happens.

func (*FML) GetStringArrayOrError

func (f *FML) GetStringArrayOrError(key string) (arr []string, err error)

GetStringArrayOrError gets an array of string from the node.

func (*FML) GetStringOrDefault

func (f *FML) GetStringOrDefault(key string, defaultVal string) string

GetStringOrDefault gets a string value from the node, or return defaultVal if the key does not exist or other error happens.

func (*FML) GetStringOrError

func (f *FML) GetStringOrError(key string) (val string, err error)

GetStringOrError gets a string value from the node.

func (*FML) GetStruct

func (f *FML) GetStruct(key string, v interface{}) (err error)

GetStruct get a struct from the node

func (*FML) GetTimeArray

func (f *FML) GetTimeArray(key string) []time.Time

GetDatetimeArray gets an array of time.Time from the node. It returns nil if the key does not exist or other error happens.

func (*FML) GetTimeArrayOrError

func (f *FML) GetTimeArrayOrError(key string) (arr []time.Time, err error)

GetDatetimeArray gets an array of time.Time from the node.

func (*FML) GetTimeOrError

func (f *FML) GetTimeOrError(key string) (val time.Time, err error)

GetTimeOrError gets a time.Time value from the node.

func (*FML) KeySet

func (f *FML) KeySet() (keys []string)

func (*FML) RemoveItem

func (f *FML) RemoveItem(key string)

func (*FML) SetValue

func (f *FML) SetValue(key string, v interface{})

func (*FML) ValueSet

func (f *FML) ValueSet() (values []interface{})

func (*FML) WriteTo

func (f *FML) WriteTo(writer *bufio.Writer)

func (*FML) WriteToFile

func (f *FML) WriteToFile(path string) (err error)

Jump to

Keyboard shortcuts

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