unit

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2024 License: MIT Imports: 5 Imported by: 1

README

unit

reads and builds a map[string]string from a simple unit style resource file

./sample

[sample]
key1 = value1
key2 = value2

[sample2]
# comments are supported as are colon seperators and 
# multi-segemented values are not disturbed on parse
key1 : value1
key2 : value2,value3,value4
key3 : value3:value4:value5
key4 : value4=value5

	var u unit.Unit
	u.Parse("./sample", "sample")    

	// u = map{key1:value1, key2:value2}
	fmt.Println(u)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Append added in v1.1.0

func Append(path, section, key, value string)

Append the key=value item under unit file section at the head along with a timestamp reference comment; does not validate or provide any assurances that the key is unique

func Reader added in v1.1.0

func Reader(path string, section ...string) map[string]string

Reader will parse the unit file and build the key=value map[string]string from the stated section; multiple keys have their values joined as comma delimited

func Writer added in v1.1.0

func Writer(path, section string, kv map[string]string)

Writer creates a unit file with a defined section using the map[string\string] to configure the key=value items

Types

type Unit

type Unit map[string]string

func (*Unit) Parse

func (m *Unit) Parse(path string, section ...string) bool

Parse a unit file; path,section,...

Jump to

Keyboard shortcuts

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