Skip to content

Commit

Permalink
Merge pull request #9 from ArtisanCloud/develop
Browse files Browse the repository at this point in the history
feature(object): add object type pionter creater
  • Loading branch information
Matrix-X authored Jun 8, 2022
2 parents 4d18379 + a29cc61 commit 1b83c3f
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
13 changes: 13 additions & 0 deletions object/hashMap.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,19 @@ func FilterEmptyHashMap(mapData *HashMap) (filteredMap *HashMap) {
case *HashMap:
v = FilterEmptyHashMap(v.(*HashMap))
break
//case []interface{}:
// for _, obj := range v.([]interface{}) {
// switch obj.(type) {
// case map[string]interface{}:
// o, _ := StructToHashMap(obj)
// v = FilterEmptyHashMap(o)
// break
// default:
//
// }
// }
// break

case string:
if v.(string) == "" {
delete(*filteredMap, k)
Expand Down
38 changes: 37 additions & 1 deletion object/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/gob"
"fmt"
"log"
"time"
)

func EncodeToBytes(p interface{}) []byte {
Expand All @@ -16,4 +17,39 @@ func EncodeToBytes(p interface{}) []byte {
}
fmt.Println("uncompressed size (bytes): ", len(buf.Bytes()))
return buf.Bytes()
}
}

// Time 复制 time.Time 对象,并返回复制体的指针
func Time(t time.Time) *time.Time {
return &t
}

// String 复制 string 对象,并返回复制体的指针
func String(s string) *string {
return &s
}

// Bool 复制 bool 对象,并返回复制体的指针
func Bool(b bool) *bool {
return &b
}

// Float64 复制 float64 对象,并返回复制体的指针
func Float64(f float64) *float64 {
return &f
}

// Float32 复制 float32 对象,并返回复制体的指针
func Float32(f float32) *float32 {
return &f
}

// Int64 复制 int64 对象,并返回复制体的指针
func Int64(i int64) *int64 {
return &i
}

// Int32 复制 int64 对象,并返回复制体的指针
func Int32(i int32) *int32 {
return &i
}

0 comments on commit 1b83c3f

Please sign in to comment.