aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2018-09-26 23:36:55 +0700
committerShulhan <ms@kilabit.info>2018-09-26 23:36:55 +0700
commit12a61287b468aecf2cf61bd2f7eb14558586bec6 (patch)
tree9e74a252ccaa49c2e91c54c2187d4b6e0b36ea13
parent351ccdbdcec960358f6f94c215c4d178b2f52fd7 (diff)
downloadpakakeh.go-12a61287b468aecf2cf61bd2f7eb14558586bec6.tar.xz
lib/ini: add method to get key value as boolean
-rw-r--r--lib/ini/ini.go13
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.
//