diff options
| author | Shulhan <ms@kilabit.info> | 2018-09-26 23:36:55 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2018-09-26 23:36:55 +0700 |
| commit | 12a61287b468aecf2cf61bd2f7eb14558586bec6 (patch) | |
| tree | 9e74a252ccaa49c2e91c54c2187d4b6e0b36ea13 | |
| parent | 351ccdbdcec960358f6f94c215c4d178b2f52fd7 (diff) | |
| download | pakakeh.go-12a61287b468aecf2cf61bd2f7eb14558586bec6.tar.xz | |
lib/ini: add method to get key value as boolean
| -rw-r--r-- | lib/ini/ini.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/ini/ini.go b/lib/ini/ini.go index af376f46..fa4e26fa 100644 --- a/lib/ini/ini.go +++ b/lib/ini/ini.go @@ -286,6 +286,19 @@ func (in *Ini) GetSections(name string) (secs []*Section) { } // +// GetBool return key's value as boolean. If no key found it will return +// default value. +// +func (in *Ini) GetBool(section, subsection, key string, def bool) bool { + out, ok := in.Get(section, subsection, key) + if !ok { + return def + } + + return IsValueBoolTrue(out) +} + +// // GetString return key's value as string. if no key found it will return // default value. // |
