ini

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type File

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

func NewFile

func NewFile() *File

func Parse

func Parse(r io.Reader) (f *File, err error)

func (*File) DeleteSection

func (f *File) DeleteSection(name string)

Deletes the given key from the section.

func (File) HasSection

func (f File) HasSection(name string) bool

Does the File have the given section.

func (File) PreSection

func (f File) PreSection() *Section

Returns a Section with the key=value pairs that appear before the first section.

func (*File) Section

func (f *File) Section(name string) *Section

The section with the given name. If the section is not already present, a new section is created.

func (File) Sections

func (f File) Sections() []string

func (File) WriteTo

func (f File) WriteTo(w io.Writer) (n int64, err error)

type Section

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

func NewSection

func NewSection() *Section

func (*Section) AddValue

func (s *Section) AddValue(key string, value string)

If the key is not present, adds the key with the given value. If the key is present, add the given value as an additional line (MultivalueArray)

func (*Section) DeleteValue

func (s *Section) DeleteValue(key string)

Deletes the given key from the section.

func (Section) HasKey

func (s Section) HasKey(key string) bool

Does the section have the given key.

func (Section) Keys

func (s Section) Keys() []string

The keys with values present in the section.

func (*Section) SetValue

func (s *Section) SetValue(key string, value string)

Sets the value of key to value. This will overwrite if the key already has a value. If the value is a multivalue array, ALL values (except for the new value) will be deleted.

func (Section) Value

func (s Section) Value(key string) Value

The value associated with the key. If the key is not present, returns an empty string value.

type Value

type Value []string

Value holds the value of a Key=Value pair. If multiple lines have the same key, only the first value is used, except for with MultivalueArray.

func NewValue

func NewValue(s string) Value

func (Value) Bool

func (v Value) Bool() bool

Returns if value == "true". Other values returns false. Case insensitive.

func (Value) CommaArray

func (v Value) CommaArray() (out []string)

Returns the value as a comma delimited array. Each output is trimmed.

func (Value) File

func (v Value) File() (*os.File, error)

Attempts to open the file pointed to by the value.

func (Value) Int

func (v Value) Int() int

Returns as an int. If ! IsInt, returns 0.

func (Value) IsBool

func (v Value) IsBool() bool

Returns if value is a bool value (only true and false are allowed). Case insensitive.

func (Value) IsCommaArray

func (v Value) IsCommaArray() bool

Returns if the value contains any commas, perhaps indicating that it's a comma delimited array.

func (Value) IsInt

func (v Value) IsInt() bool

Returns if value is an int.

func (Value) IsMultivalueArray

func (v Value) IsMultivalueArray() bool

Returns if there are multiple value with this same key.

func (Value) IsSemicolonArray

func (v Value) IsSemicolonArray() bool

Returns if the value contains any semicolons, perhaps indicating that it's a semicolon delimited array.

func (Value) MultivalueArray

func (v Value) MultivalueArray() []string

Returns all values with the same key.

func (Value) SemicolonArray

func (v Value) SemicolonArray() (out []string)

Returns the value as a semicolon delimited array. Each output is trimmed.

func (Value) String

func (v Value) String() string

Returns the value as a string.

Jump to

Keyboard shortcuts

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