From: qydysky Date: Sun, 14 Mar 2021 02:51:39 +0000 (+0800) Subject: uintptr string X-Git-Tag: v0.4.12 X-Git-Url: http://127.0.0.1:8081/?a=commitdiff_plain;h=ea4797fedbb950cda38ea902c20b669bd5d9a5b2;p=part%2F.git uintptr string --- diff --git a/tmplKV/tmplV_test.go b/tmplKV/tmplV_test.go index f87fb5c..5293d59 100644 --- a/tmplKV/tmplV_test.go +++ b/tmplKV/tmplV_test.go @@ -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 index 0000000..916aa58 --- /dev/null +++ b/tmplKV/util.go @@ -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