]> 127.0.0.1 Git - part/.git/commitdiff
uintptr string v0.4.12
authorqydysky <qydysky@foxmail.com>
Sun, 14 Mar 2021 02:51:39 +0000 (10:51 +0800)
committerqydysky <qydysky@foxmail.com>
Sun, 14 Mar 2021 02:51:39 +0000 (10:51 +0800)
tmplKV/tmplV_test.go
tmplKV/util.go [new file with mode: 0644]

index f87fb5c4997ac744f75e96caa68ce8c2c3576982..5293d59eb12d5bce43168d1223bc54243ab10593 100644 (file)
@@ -11,4 +11,8 @@ func Test_tmplV(t *testing.T) {
        if o,p := s.Buf();p != 1 || o - time.Now().Unix() > 1{return}
        if ok,k := s.Get(v);!ok || k != "a" {return}
        if !s.Check(v, "a") {return}
+       ps := Uintptr2String(v)
+       if v != String2Uintptr(ps) {
+               t.Error(`aaa`)
+       }
 }
diff --git a/tmplKV/util.go b/tmplKV/util.go
new file mode 100644 (file)
index 0000000..916aa58
--- /dev/null
@@ -0,0 +1,20 @@
+package part
+
+import (
+       "fmt"
+       "strconv"
+)
+
+func Uintptr2String(ptr uintptr) string {
+       return fmt.Sprint(ptr)
+}
+
+
+func String2Uintptr(s string) (ptr uintptr) {
+       if i,e := strconv.Atoi(s);e != nil {
+               return
+       } else {
+               ptr = uintptr(i)
+       }
+       return
+}
\ No newline at end of file