Documentation
¶
Overview ¶
Package ini provides INI file read and write functionality in Go.
Index ¶
- Constants
- Variables
- type File
- func (f *File) Append(source interface{}, others ...interface{}) error
- func (f *File) DeleteSection(name string)
- func (f *File) GetSection(name string) (*Section, error)
- func (f *File) NewSection(name string) (*Section, error)
- func (f *File) Reload() error
- func (f *File) SaveTo(filename string) (err error)
- func (f *File) Section(name string) *Section
- func (f *File) SectionStrings() []string
- func (f *File) Sections() []*Section
- type Key
- func (k *Key) Bool() (bool, error)
- func (k *Key) Expand() string
- func (k *Key) Float64() (float64, error)
- func (k *Key) Float64s(delim string) []float64
- func (k *Key) In(defaultVal string, candidates []string) string
- func (k *Key) InFloat64(defaultVal float64, candidates []float64) float64
- func (k *Key) InInt(defaultVal int, candidates []int) int
- func (k *Key) InInt64(defaultVal int64, candidates []int64) int64
- func (k *Key) Int() (int, error)
- func (k *Key) Int64() (int64, error)
- func (k *Key) Int64s(delim string) []int64
- func (k *Key) Ints(delim string) []int
- func (k *Key) MustBool(defaultVal ...bool) bool
- func (k *Key) MustFloat64(defaultVal ...float64) float64
- func (k *Key) MustInt(defaultVal ...int) int
- func (k *Key) MustInt64(defaultVal ...int64) int64
- func (k *Key) Name() string
- func (k *Key) SetValue(v string)
- func (k *Key) String() string
- func (k *Key) Strings(delim string) []string
- func (k *Key) Value() string
- type Section
- func (s *Section) DeleteKey(name string)
- func (s *Section) GetKey(name string) (*Key, error)
- func (s *Section) Key(name string) *Key
- func (s *Section) KeyStrings() []string
- func (s *Section) Keys() []*Key
- func (s *Section) KeysHash(unquote bool) map[string]string
- func (s *Section) Name() string
- func (s *Section) NewKey(name, val string) (*Key, error)
Constants ¶
const (
// DefaultSection is the name of empty section
DefaultSection = "DEFAULT"
)
Variables ¶
var ( // LineBreak depends on OS. LF by default (Linux) LineBreak = "\n" // PrettyFormat put spaces around "=" to look better. PrettyFormat = true // UnquoteValues strips "quotation marks" from values UnquoteValues = true )
Functions ¶
This section is empty.
Types ¶
type File ¶
type File struct {
// Should make things safe, but sometimes doesn't matter.
BlockMode bool
// contains filtered or unexported fields
}
File represents a combination of a or more INI file(s) in memory.
func Load ¶
Load loads and parses from INI data sources. Arguments can be mixed of file name with string type, or raw data in []byte.
func (*File) DeleteSection ¶
DeleteSection deletes a section.
func (*File) GetSection ¶
GetSection returns section by given name.
func (*File) NewSection ¶
NewSection creates a new section.
func (*File) SectionStrings ¶
SectionStrings returns list of section names.
type Key ¶
type Key struct {
Comment string
// contains filtered or unexported fields
}
Key represents a key under a section.
func (*Key) In ¶
In always returns value without error, it returns default value if error occurs or doesn't fit into candidates.
func (*Key) InFloat64 ¶
InFloat64 always returns value without error, it returns default value if error occurs or doesn't fit into candidates.
func (*Key) InInt ¶
InInt always returns value without error, it returns default value if error occurs or doesn't fit into candidates.
func (*Key) InInt64 ¶
InInt64 always returns value without error, it returns default value if error occurs or doesn't fit into candidates.
func (*Key) MustBool ¶
MustBool always returns value without error, it returns false if error occurs.
func (*Key) MustFloat64 ¶
MustFloat64 always returns value without error, it returns 0.0 if error occurs.
type Section ¶
type Section struct {
Comment string
// contains filtered or unexported fields
}
Section represents a config section.
func (*Section) KeyStrings ¶
KeyStrings returns list of key names of section.
