]> 127.0.0.1 Git - part/.git/commitdiff
88 v0.1.1
authorqydysky <qydysky@foxmail.com>
Fri, 30 Oct 2020 19:18:06 +0000 (03:18 +0800)
committerqydysky <qydysky@foxmail.com>
Fri, 30 Oct 2020 19:18:06 +0000 (03:18 +0800)
buf/map.go [moved from setting/Setting.go with 68% similarity]

similarity index 68%
rename from setting/Setting.go
rename to buf/map.go
index 11a9d8dedaeed266a1947064c5cfd45e4bebf99f..3d19ec273f4434d36b160a56ee48e1f26d6097ee 100644 (file)
@@ -5,22 +5,22 @@ import (
        "github.com/thedevsaddam/gojsonq/v2"
 )
 
-type Setting struct {
+type Map struct {
        B map[string]interface{}
 }
 
-func New() *Setting {
-       b := new(Setting)
+func New() *Map {
+       b := new(Map)
        b.B = make(map[string]interface{})
        return b
 } 
 
-func (i *Setting) Get(key string) (interface{},bool) {
+func (i *Map) Get(key string) (interface{},bool) {
        v,ok := i.B[key]
        return v,ok
 }
 
-func (i *Setting) Set(key string,val interface{}) bool {
+func (i *Map) Set(key string,val interface{}) bool {
        switch val.(type) {
        case string,bool,int,float64:
                i.B[key] = val
@@ -30,7 +30,7 @@ func (i *Setting) Set(key string,val interface{}) bool {
        return false
 }
 
-func (i *Setting) Save(Source string) error {
+func (i *Map) Save(Source string) error {
        js := gojsonq.New().FromInterface(i.B)
        fileObj,err := os.OpenFile(Source,os.O_RDWR|os.O_EXCL,0644)
        if err != nil {return err}
@@ -39,7 +39,7 @@ func (i *Setting) Save(Source string) error {
        return nil
 }
 
-func (i *Setting) Load(Source string) {
+func (i *Map) Load(Source string) {
        if b := gojsonq.New().File(Source).Get();b != nil{
                i.B = b.(map[string]interface {})
        }