+++ /dev/null
-package part
-
-import (
- "math/rand"
- "time"
- "bytes"
-)
-
-type stringl struct{}
-
-func Stringf() *stringl {
- return &stringl{}
-}
-
-func (t *stringl)Rand(typel,leng int) string {
- source := "0123456789"
- if typel > 0 {source+="abcdefghijklmnopqrstuvwxyz"}
- if typel > 1 {source+="ABCDEFGHIJKLMNOPQRSTUVWXYZ"}
-
- Letters := []rune(source)
- LettersL := len(Letters)
- r := rand.New(rand.NewSource(time.Now().UnixNano()))
- var bb bytes.Buffer
- bb.Grow(leng)
- for i := 0; i < leng; i++ {
- bb.WriteRune(Letters[r.Intn(LettersL)])
- }
- return bb.String()
-
-}
--- /dev/null
+package part
+
+import (
+ "bytes"
+ "math/rand"
+ "strconv"
+ "strings"
+ "time"
+)
+
+const (
+ Number RandType = 0
+ lowNumber RandType = 1
+ uppNumber RandType = 2
+)
+
+type RandType int
+
+func Rand(typel RandType, leng int) string {
+ source := "0123456789"
+ if typel > 0 {
+ source += "abcdefghijklmnopqrstuvwxyz"
+ }
+ if typel > 1 {
+ source += "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ }
+
+ Letters := []rune(source)
+ LettersL := len(Letters)
+ r := rand.New(rand.NewSource(time.Now().UnixNano()))
+ var bb bytes.Buffer
+ bb.Grow(leng)
+ for i := 0; i < leng; i++ {
+ bb.WriteRune(Letters[r.Intn(LettersL)])
+ }
+ return bb.String()
+
+}
+
+func UnescapeUnicode(raw string) (string, error) {
+ return strconv.Unquote(strings.Replace(strconv.Quote(raw), `\\u`, `\u`, -1))
+}
--- /dev/null
+package part
+
+import (
+ "testing"
+)
+
+func Test_Rand(t *testing.T) {
+ t.Log(Rand(Number, 14))
+ t.Log(Rand(lowNumber, 14))
+ t.Log(Rand(uppNumber, 14))
+}
+
+func Test_UnescapeUnicode(t *testing.T) {
+ s, e := UnescapeUnicode("\uB155, \uC138\uC0C1(\u4E16\u4E0A). \u263a")
+ t.Log(s)
+ t.Log(e)
+}