mirror of
https://github.com/duke-git/lancet.git
synced 2026-02-15 10:12:29 +08:00
doc: update doc for new added functions
This commit is contained in:
@@ -466,12 +466,6 @@ func TestGbkToUtf8(t *testing.T) {
|
|||||||
assert.Equal("hello", string(utf8Data))
|
assert.Equal("hello", string(utf8Data))
|
||||||
}
|
}
|
||||||
|
|
||||||
func decodeBase64(data []byte) ([]byte, error) {
|
|
||||||
buf := make([]byte, base64.StdEncoding.DecodedLen(len(data)))
|
|
||||||
n, err := base64.StdEncoding.Decode(buf, data)
|
|
||||||
return buf[:n], err
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestToStdBase64(t *testing.T) {
|
func TestToStdBase64(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
assert := internal.NewAssert(t, "TestToStdBase64")
|
assert := internal.NewAssert(t, "TestToStdBase64")
|
||||||
|
|||||||
@@ -903,52 +903,52 @@ import (
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
afterEncode := convertor.ToStdBase64(nil)
|
afterEncode := convertor.ToStdBase64(nil)
|
||||||
fmt.Println(afterEncode)
|
fmt.Println(afterEncode)
|
||||||
|
|
||||||
afterEncode = convertor.ToStdBase64("")
|
afterEncode = convertor.ToStdBase64("")
|
||||||
fmt.Println(afterEncode)
|
fmt.Println(afterEncode)
|
||||||
|
|
||||||
stringVal := "hello"
|
stringVal := "hello"
|
||||||
afterEncode = convertor.ToStdBase64(stringVal)
|
afterEncode = convertor.ToStdBase64(stringVal)
|
||||||
fmt.Println(afterEncode)
|
fmt.Println(afterEncode)
|
||||||
|
|
||||||
byteSliceVal := []byte("hello")
|
byteSliceVal := []byte("hello")
|
||||||
afterEncode = convertor.ToStdBase64(byteSliceVal)
|
afterEncode = convertor.ToStdBase64(byteSliceVal)
|
||||||
fmt.Println(afterEncode)
|
fmt.Println(afterEncode)
|
||||||
|
|
||||||
intVal := 123
|
intVal := 123
|
||||||
afterEncode = convertor.ToStdBase64(intVal)
|
afterEncode = convertor.ToStdBase64(intVal)
|
||||||
fmt.Println(afterEncode)
|
fmt.Println(afterEncode)
|
||||||
|
|
||||||
mapVal := map[string]any{"a": "hi", "b": 2, "c": struct {
|
mapVal := map[string]any{"a": "hi", "b": 2, "c": struct {
|
||||||
A string
|
A string
|
||||||
B int
|
B int
|
||||||
}{"hello", 3}}
|
}{"hello", 3}}
|
||||||
afterEncode = convertor.ToStdBase64(mapVal)
|
afterEncode = convertor.ToStdBase64(mapVal)
|
||||||
fmt.Println(afterEncode)
|
fmt.Println(afterEncode)
|
||||||
|
|
||||||
floatVal := 123.456
|
floatVal := 123.456
|
||||||
afterEncode = convertor.ToStdBase64(floatVal)
|
afterEncode = convertor.ToStdBase64(floatVal)
|
||||||
fmt.Println(afterEncode)
|
fmt.Println(afterEncode)
|
||||||
|
|
||||||
boolVal := true
|
boolVal := true
|
||||||
afterEncode = convertor.ToStdBase64(boolVal)
|
afterEncode = convertor.ToStdBase64(boolVal)
|
||||||
fmt.Println(afterEncode)
|
fmt.Println(afterEncode)
|
||||||
|
|
||||||
errVal := errors.New("err")
|
errVal := errors.New("err")
|
||||||
afterEncode = convertor.ToStdBase64(errVal)
|
afterEncode = convertor.ToStdBase64(errVal)
|
||||||
fmt.Println(afterEncode)
|
fmt.Println(afterEncode)
|
||||||
|
|
||||||
// Output:
|
// Output:
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// aGVsbG8=
|
// aGVsbG8=
|
||||||
// aGVsbG8=
|
// aGVsbG8=
|
||||||
// MTIz
|
// MTIz
|
||||||
// eyJhIjoiaGkiLCJiIjoyLCJjIjp7IkEiOiJoZWxsbyIsIkIiOjN9fQ==
|
// eyJhIjoiaGkiLCJiIjoyLCJjIjp7IkEiOiJoZWxsbyIsIkIiOjN9fQ==
|
||||||
// MTIzLjQ1Ng==
|
// MTIzLjQ1Ng==
|
||||||
// dHJ1ZQ==
|
// dHJ1ZQ==
|
||||||
// ZXJy
|
// ZXJy
|
||||||
}
|
}
|
||||||
|
|
||||||
```
|
```
|
||||||
@@ -975,49 +975,49 @@ import (
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
afterEncode := convertor.ToUrlBase64(nil)
|
afterEncode := convertor.ToUrlBase64(nil)
|
||||||
fmt.Println(afterEncode)
|
fmt.Println(afterEncode)
|
||||||
|
|
||||||
|
|
||||||
stringVal := "hello"
|
stringVal := "hello"
|
||||||
afterEncode = convertor.ToUrlBase64(stringVal)
|
afterEncode = convertor.ToUrlBase64(stringVal)
|
||||||
fmt.Println(afterEncode)
|
fmt.Println(afterEncode)
|
||||||
|
|
||||||
byteSliceVal := []byte("hello")
|
byteSliceVal := []byte("hello")
|
||||||
afterEncode = convertor.ToUrlBase64(byteSliceVal)
|
afterEncode = convertor.ToUrlBase64(byteSliceVal)
|
||||||
fmt.Println(afterEncode)
|
fmt.Println(afterEncode)
|
||||||
|
|
||||||
intVal := 123
|
intVal := 123
|
||||||
afterEncode = convertor.ToUrlBase64(intVal)
|
afterEncode = convertor.ToUrlBase64(intVal)
|
||||||
fmt.Println(afterEncode)
|
fmt.Println(afterEncode)
|
||||||
|
|
||||||
mapVal := map[string]any{"a": "hi", "b": 2, "c": struct {
|
mapVal := map[string]any{"a": "hi", "b": 2, "c": struct {
|
||||||
A string
|
A string
|
||||||
B int
|
B int
|
||||||
}{"hello", 3}}
|
}{"hello", 3}}
|
||||||
afterEncode = convertor.ToUrlBase64(mapVal)
|
afterEncode = convertor.ToUrlBase64(mapVal)
|
||||||
fmt.Println(afterEncode)
|
fmt.Println(afterEncode)
|
||||||
|
|
||||||
floatVal := 123.456
|
floatVal := 123.456
|
||||||
afterEncode = convertor.ToUrlBase64(floatVal)
|
afterEncode = convertor.ToUrlBase64(floatVal)
|
||||||
fmt.Println(afterEncode)
|
fmt.Println(afterEncode)
|
||||||
|
|
||||||
boolVal := true
|
boolVal := true
|
||||||
afterEncode = convertor.ToUrlBase64(boolVal)
|
afterEncode = convertor.ToUrlBase64(boolVal)
|
||||||
fmt.Println(afterEncode)
|
fmt.Println(afterEncode)
|
||||||
|
|
||||||
errVal := errors.New("err")
|
errVal := errors.New("err")
|
||||||
afterEncode = convertor.ToUrlBase64(errVal)
|
afterEncode = convertor.ToUrlBase64(errVal)
|
||||||
fmt.Println(afterEncode)
|
fmt.Println(afterEncode)
|
||||||
|
|
||||||
// Output:
|
// Output:
|
||||||
//
|
//
|
||||||
// aGVsbG8=
|
// aGVsbG8=
|
||||||
// aGVsbG8=
|
// aGVsbG8=
|
||||||
// MTIz
|
// MTIz
|
||||||
// eyJhIjoiaGkiLCJiIjoyLCJjIjp7IkEiOiJoZWxsbyIsIkIiOjN9fQ==
|
// eyJhIjoiaGkiLCJiIjoyLCJjIjp7IkEiOiJoZWxsbyIsIkIiOjN9fQ==
|
||||||
// MTIzLjQ1Ng==
|
// MTIzLjQ1Ng==
|
||||||
// dHJ1ZQ==
|
// dHJ1ZQ==
|
||||||
// ZXJy
|
// ZXJy
|
||||||
}
|
}
|
||||||
|
|
||||||
```
|
```
|
||||||
@@ -1044,45 +1044,45 @@ import (
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
stringVal := "hello"
|
stringVal := "hello"
|
||||||
afterEncode = convertor.ToRawStdBase64(stringVal)
|
afterEncode = convertor.ToRawStdBase64(stringVal)
|
||||||
fmt.Println(afterEncode)
|
fmt.Println(afterEncode)
|
||||||
|
|
||||||
byteSliceVal := []byte("hello")
|
byteSliceVal := []byte("hello")
|
||||||
afterEncode = convertor.ToRawStdBase64(byteSliceVal)
|
afterEncode = convertor.ToRawStdBase64(byteSliceVal)
|
||||||
fmt.Println(afterEncode)
|
fmt.Println(afterEncode)
|
||||||
|
|
||||||
intVal := 123
|
intVal := 123
|
||||||
afterEncode = convertor.ToRawStdBase64(intVal)
|
afterEncode = convertor.ToRawStdBase64(intVal)
|
||||||
fmt.Println(afterEncode)
|
fmt.Println(afterEncode)
|
||||||
|
|
||||||
mapVal := map[string]any{"a": "hi", "b": 2, "c": struct {
|
mapVal := map[string]any{"a": "hi", "b": 2, "c": struct {
|
||||||
A string
|
A string
|
||||||
B int
|
B int
|
||||||
}{"hello", 3}}
|
}{"hello", 3}}
|
||||||
afterEncode = convertor.ToRawStdBase64(mapVal)
|
afterEncode = convertor.ToRawStdBase64(mapVal)
|
||||||
fmt.Println(afterEncode)
|
fmt.Println(afterEncode)
|
||||||
|
|
||||||
floatVal := 123.456
|
floatVal := 123.456
|
||||||
afterEncode = convertor.ToRawStdBase64(floatVal)
|
afterEncode = convertor.ToRawStdBase64(floatVal)
|
||||||
fmt.Println(afterEncode)
|
fmt.Println(afterEncode)
|
||||||
|
|
||||||
boolVal := true
|
boolVal := true
|
||||||
afterEncode = convertor.ToRawStdBase64(boolVal)
|
afterEncode = convertor.ToRawStdBase64(boolVal)
|
||||||
fmt.Println(afterEncode)
|
fmt.Println(afterEncode)
|
||||||
|
|
||||||
errVal := errors.New("err")
|
errVal := errors.New("err")
|
||||||
afterEncode = convertor.ToRawStdBase64(errVal)
|
afterEncode = convertor.ToRawStdBase64(errVal)
|
||||||
fmt.Println(afterEncode)
|
fmt.Println(afterEncode)
|
||||||
|
|
||||||
// Output:
|
// Output:
|
||||||
// aGVsbG8
|
// aGVsbG8
|
||||||
// aGVsbG8
|
// aGVsbG8
|
||||||
// MTIz
|
// MTIz
|
||||||
// eyJhIjoiaGkiLCJiIjoyLCJjIjp7IkEiOiJoZWxsbyIsIkIiOjN9fQ
|
// eyJhIjoiaGkiLCJiIjoyLCJjIjp7IkEiOiJoZWxsbyIsIkIiOjN9fQ
|
||||||
// MTIzLjQ1Ng
|
// MTIzLjQ1Ng
|
||||||
// dHJ1ZQ
|
// dHJ1ZQ
|
||||||
// ZXJy
|
// ZXJy
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -1108,44 +1108,44 @@ import (
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
stringVal := "hello"
|
stringVal := "hello"
|
||||||
afterEncode = convertor.ToRawUrlBase64(stringVal)
|
afterEncode = convertor.ToRawUrlBase64(stringVal)
|
||||||
fmt.Println(afterEncode)
|
fmt.Println(afterEncode)
|
||||||
|
|
||||||
byteSliceVal := []byte("hello")
|
byteSliceVal := []byte("hello")
|
||||||
afterEncode = convertor.ToRawUrlBase64(byteSliceVal)
|
afterEncode = convertor.ToRawUrlBase64(byteSliceVal)
|
||||||
fmt.Println(afterEncode)
|
fmt.Println(afterEncode)
|
||||||
|
|
||||||
intVal := 123
|
intVal := 123
|
||||||
afterEncode = convertor.ToRawUrlBase64(intVal)
|
afterEncode = convertor.ToRawUrlBase64(intVal)
|
||||||
fmt.Println(afterEncode)
|
fmt.Println(afterEncode)
|
||||||
|
|
||||||
mapVal := map[string]any{"a": "hi", "b": 2, "c": struct {
|
mapVal := map[string]any{"a": "hi", "b": 2, "c": struct {
|
||||||
A string
|
A string
|
||||||
B int
|
B int
|
||||||
}{"hello", 3}}
|
}{"hello", 3}}
|
||||||
afterEncode = convertor.ToRawUrlBase64(mapVal)
|
afterEncode = convertor.ToRawUrlBase64(mapVal)
|
||||||
fmt.Println(afterEncode)
|
fmt.Println(afterEncode)
|
||||||
|
|
||||||
floatVal := 123.456
|
floatVal := 123.456
|
||||||
afterEncode = convertor.ToRawUrlBase64(floatVal)
|
afterEncode = convertor.ToRawUrlBase64(floatVal)
|
||||||
fmt.Println(afterEncode)
|
fmt.Println(afterEncode)
|
||||||
|
|
||||||
boolVal := true
|
boolVal := true
|
||||||
afterEncode = convertor.ToRawStdBase64(boolVal)
|
afterEncode = convertor.ToRawStdBase64(boolVal)
|
||||||
fmt.Println(afterEncode)
|
fmt.Println(afterEncode)
|
||||||
|
|
||||||
errVal := errors.New("err")
|
errVal := errors.New("err")
|
||||||
afterEncode = convertor.ToRawStdBase64(errVal)
|
afterEncode = convertor.ToRawStdBase64(errVal)
|
||||||
fmt.Println(afterEncode)
|
fmt.Println(afterEncode)
|
||||||
|
|
||||||
// Output:
|
// Output:
|
||||||
// aGVsbG8
|
// aGVsbG8
|
||||||
// aGVsbG8
|
// aGVsbG8
|
||||||
// MTIz
|
// MTIz
|
||||||
// eyJhIjoiaGkiLCJiIjoyLCJjIjp7IkEiOiJoZWxsbyIsIkIiOjN9fQ
|
// eyJhIjoiaGkiLCJiIjoyLCJjIjp7IkEiOiJoZWxsbyIsIkIiOjN9fQ
|
||||||
// MTIzLjQ1Ng
|
// MTIzLjQ1Ng
|
||||||
// dHJ1ZQ
|
// dHJ1ZQ
|
||||||
// ZXJy
|
// ZXJy
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@@ -903,52 +903,52 @@ import (
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
afterEncode := convertor.ToStdBase64(nil)
|
afterEncode := convertor.ToStdBase64(nil)
|
||||||
fmt.Println(afterEncode)
|
fmt.Println(afterEncode)
|
||||||
|
|
||||||
afterEncode = convertor.ToStdBase64("")
|
afterEncode = convertor.ToStdBase64("")
|
||||||
fmt.Println(afterEncode)
|
fmt.Println(afterEncode)
|
||||||
|
|
||||||
stringVal := "hello"
|
stringVal := "hello"
|
||||||
afterEncode = convertor.ToStdBase64(stringVal)
|
afterEncode = convertor.ToStdBase64(stringVal)
|
||||||
fmt.Println(afterEncode)
|
fmt.Println(afterEncode)
|
||||||
|
|
||||||
byteSliceVal := []byte("hello")
|
byteSliceVal := []byte("hello")
|
||||||
afterEncode = convertor.ToStdBase64(byteSliceVal)
|
afterEncode = convertor.ToStdBase64(byteSliceVal)
|
||||||
fmt.Println(afterEncode)
|
fmt.Println(afterEncode)
|
||||||
|
|
||||||
intVal := 123
|
intVal := 123
|
||||||
afterEncode = convertor.ToStdBase64(intVal)
|
afterEncode = convertor.ToStdBase64(intVal)
|
||||||
fmt.Println(afterEncode)
|
fmt.Println(afterEncode)
|
||||||
|
|
||||||
mapVal := map[string]any{"a": "hi", "b": 2, "c": struct {
|
mapVal := map[string]any{"a": "hi", "b": 2, "c": struct {
|
||||||
A string
|
A string
|
||||||
B int
|
B int
|
||||||
}{"hello", 3}}
|
}{"hello", 3}}
|
||||||
afterEncode = convertor.ToStdBase64(mapVal)
|
afterEncode = convertor.ToStdBase64(mapVal)
|
||||||
fmt.Println(afterEncode)
|
fmt.Println(afterEncode)
|
||||||
|
|
||||||
floatVal := 123.456
|
floatVal := 123.456
|
||||||
afterEncode = convertor.ToStdBase64(floatVal)
|
afterEncode = convertor.ToStdBase64(floatVal)
|
||||||
fmt.Println(afterEncode)
|
fmt.Println(afterEncode)
|
||||||
|
|
||||||
boolVal := true
|
boolVal := true
|
||||||
afterEncode = convertor.ToStdBase64(boolVal)
|
afterEncode = convertor.ToStdBase64(boolVal)
|
||||||
fmt.Println(afterEncode)
|
fmt.Println(afterEncode)
|
||||||
|
|
||||||
errVal := errors.New("err")
|
errVal := errors.New("err")
|
||||||
afterEncode = convertor.ToStdBase64(errVal)
|
afterEncode = convertor.ToStdBase64(errVal)
|
||||||
fmt.Println(afterEncode)
|
fmt.Println(afterEncode)
|
||||||
|
|
||||||
// Output:
|
// Output:
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// aGVsbG8=
|
// aGVsbG8=
|
||||||
// aGVsbG8=
|
// aGVsbG8=
|
||||||
// MTIz
|
// MTIz
|
||||||
// eyJhIjoiaGkiLCJiIjoyLCJjIjp7IkEiOiJoZWxsbyIsIkIiOjN9fQ==
|
// eyJhIjoiaGkiLCJiIjoyLCJjIjp7IkEiOiJoZWxsbyIsIkIiOjN9fQ==
|
||||||
// MTIzLjQ1Ng==
|
// MTIzLjQ1Ng==
|
||||||
// dHJ1ZQ==
|
// dHJ1ZQ==
|
||||||
// ZXJy
|
// ZXJy
|
||||||
}
|
}
|
||||||
|
|
||||||
```
|
```
|
||||||
@@ -975,49 +975,49 @@ import (
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
afterEncode := convertor.ToUrlBase64(nil)
|
afterEncode := convertor.ToUrlBase64(nil)
|
||||||
fmt.Println(afterEncode)
|
fmt.Println(afterEncode)
|
||||||
|
|
||||||
|
|
||||||
stringVal := "hello"
|
stringVal := "hello"
|
||||||
afterEncode = convertor.ToUrlBase64(stringVal)
|
afterEncode = convertor.ToUrlBase64(stringVal)
|
||||||
fmt.Println(afterEncode)
|
fmt.Println(afterEncode)
|
||||||
|
|
||||||
byteSliceVal := []byte("hello")
|
byteSliceVal := []byte("hello")
|
||||||
afterEncode = convertor.ToUrlBase64(byteSliceVal)
|
afterEncode = convertor.ToUrlBase64(byteSliceVal)
|
||||||
fmt.Println(afterEncode)
|
fmt.Println(afterEncode)
|
||||||
|
|
||||||
intVal := 123
|
intVal := 123
|
||||||
afterEncode = convertor.ToUrlBase64(intVal)
|
afterEncode = convertor.ToUrlBase64(intVal)
|
||||||
fmt.Println(afterEncode)
|
fmt.Println(afterEncode)
|
||||||
|
|
||||||
mapVal := map[string]any{"a": "hi", "b": 2, "c": struct {
|
mapVal := map[string]any{"a": "hi", "b": 2, "c": struct {
|
||||||
A string
|
A string
|
||||||
B int
|
B int
|
||||||
}{"hello", 3}}
|
}{"hello", 3}}
|
||||||
afterEncode = convertor.ToUrlBase64(mapVal)
|
afterEncode = convertor.ToUrlBase64(mapVal)
|
||||||
fmt.Println(afterEncode)
|
fmt.Println(afterEncode)
|
||||||
|
|
||||||
floatVal := 123.456
|
floatVal := 123.456
|
||||||
afterEncode = convertor.ToUrlBase64(floatVal)
|
afterEncode = convertor.ToUrlBase64(floatVal)
|
||||||
fmt.Println(afterEncode)
|
fmt.Println(afterEncode)
|
||||||
|
|
||||||
boolVal := true
|
boolVal := true
|
||||||
afterEncode = convertor.ToUrlBase64(boolVal)
|
afterEncode = convertor.ToUrlBase64(boolVal)
|
||||||
fmt.Println(afterEncode)
|
fmt.Println(afterEncode)
|
||||||
|
|
||||||
errVal := errors.New("err")
|
errVal := errors.New("err")
|
||||||
afterEncode = convertor.ToUrlBase64(errVal)
|
afterEncode = convertor.ToUrlBase64(errVal)
|
||||||
fmt.Println(afterEncode)
|
fmt.Println(afterEncode)
|
||||||
|
|
||||||
// Output:
|
// Output:
|
||||||
//
|
//
|
||||||
// aGVsbG8=
|
// aGVsbG8=
|
||||||
// aGVsbG8=
|
// aGVsbG8=
|
||||||
// MTIz
|
// MTIz
|
||||||
// eyJhIjoiaGkiLCJiIjoyLCJjIjp7IkEiOiJoZWxsbyIsIkIiOjN9fQ==
|
// eyJhIjoiaGkiLCJiIjoyLCJjIjp7IkEiOiJoZWxsbyIsIkIiOjN9fQ==
|
||||||
// MTIzLjQ1Ng==
|
// MTIzLjQ1Ng==
|
||||||
// dHJ1ZQ==
|
// dHJ1ZQ==
|
||||||
// ZXJy
|
// ZXJy
|
||||||
}
|
}
|
||||||
|
|
||||||
```
|
```
|
||||||
@@ -1044,45 +1044,45 @@ import (
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
stringVal := "hello"
|
stringVal := "hello"
|
||||||
afterEncode = convertor.ToRawStdBase64(stringVal)
|
afterEncode = convertor.ToRawStdBase64(stringVal)
|
||||||
fmt.Println(afterEncode)
|
fmt.Println(afterEncode)
|
||||||
|
|
||||||
byteSliceVal := []byte("hello")
|
byteSliceVal := []byte("hello")
|
||||||
afterEncode = convertor.ToRawStdBase64(byteSliceVal)
|
afterEncode = convertor.ToRawStdBase64(byteSliceVal)
|
||||||
fmt.Println(afterEncode)
|
fmt.Println(afterEncode)
|
||||||
|
|
||||||
intVal := 123
|
intVal := 123
|
||||||
afterEncode = convertor.ToRawStdBase64(intVal)
|
afterEncode = convertor.ToRawStdBase64(intVal)
|
||||||
fmt.Println(afterEncode)
|
fmt.Println(afterEncode)
|
||||||
|
|
||||||
mapVal := map[string]any{"a": "hi", "b": 2, "c": struct {
|
mapVal := map[string]any{"a": "hi", "b": 2, "c": struct {
|
||||||
A string
|
A string
|
||||||
B int
|
B int
|
||||||
}{"hello", 3}}
|
}{"hello", 3}}
|
||||||
afterEncode = convertor.ToRawStdBase64(mapVal)
|
afterEncode = convertor.ToRawStdBase64(mapVal)
|
||||||
fmt.Println(afterEncode)
|
fmt.Println(afterEncode)
|
||||||
|
|
||||||
floatVal := 123.456
|
floatVal := 123.456
|
||||||
afterEncode = convertor.ToRawStdBase64(floatVal)
|
afterEncode = convertor.ToRawStdBase64(floatVal)
|
||||||
fmt.Println(afterEncode)
|
fmt.Println(afterEncode)
|
||||||
|
|
||||||
boolVal := true
|
boolVal := true
|
||||||
afterEncode = convertor.ToRawStdBase64(boolVal)
|
afterEncode = convertor.ToRawStdBase64(boolVal)
|
||||||
fmt.Println(afterEncode)
|
fmt.Println(afterEncode)
|
||||||
|
|
||||||
errVal := errors.New("err")
|
errVal := errors.New("err")
|
||||||
afterEncode = convertor.ToRawStdBase64(errVal)
|
afterEncode = convertor.ToRawStdBase64(errVal)
|
||||||
fmt.Println(afterEncode)
|
fmt.Println(afterEncode)
|
||||||
|
|
||||||
// Output:
|
// Output:
|
||||||
// aGVsbG8
|
// aGVsbG8
|
||||||
// aGVsbG8
|
// aGVsbG8
|
||||||
// MTIz
|
// MTIz
|
||||||
// eyJhIjoiaGkiLCJiIjoyLCJjIjp7IkEiOiJoZWxsbyIsIkIiOjN9fQ
|
// eyJhIjoiaGkiLCJiIjoyLCJjIjp7IkEiOiJoZWxsbyIsIkIiOjN9fQ
|
||||||
// MTIzLjQ1Ng
|
// MTIzLjQ1Ng
|
||||||
// dHJ1ZQ
|
// dHJ1ZQ
|
||||||
// ZXJy
|
// ZXJy
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -1108,44 +1108,44 @@ import (
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
stringVal := "hello"
|
stringVal := "hello"
|
||||||
afterEncode = convertor.ToRawUrlBase64(stringVal)
|
afterEncode = convertor.ToRawUrlBase64(stringVal)
|
||||||
fmt.Println(afterEncode)
|
fmt.Println(afterEncode)
|
||||||
|
|
||||||
byteSliceVal := []byte("hello")
|
byteSliceVal := []byte("hello")
|
||||||
afterEncode = convertor.ToRawUrlBase64(byteSliceVal)
|
afterEncode = convertor.ToRawUrlBase64(byteSliceVal)
|
||||||
fmt.Println(afterEncode)
|
fmt.Println(afterEncode)
|
||||||
|
|
||||||
intVal := 123
|
intVal := 123
|
||||||
afterEncode = convertor.ToRawUrlBase64(intVal)
|
afterEncode = convertor.ToRawUrlBase64(intVal)
|
||||||
fmt.Println(afterEncode)
|
fmt.Println(afterEncode)
|
||||||
|
|
||||||
mapVal := map[string]any{"a": "hi", "b": 2, "c": struct {
|
mapVal := map[string]any{"a": "hi", "b": 2, "c": struct {
|
||||||
A string
|
A string
|
||||||
B int
|
B int
|
||||||
}{"hello", 3}}
|
}{"hello", 3}}
|
||||||
afterEncode = convertor.ToRawUrlBase64(mapVal)
|
afterEncode = convertor.ToRawUrlBase64(mapVal)
|
||||||
fmt.Println(afterEncode)
|
fmt.Println(afterEncode)
|
||||||
|
|
||||||
floatVal := 123.456
|
floatVal := 123.456
|
||||||
afterEncode = convertor.ToRawUrlBase64(floatVal)
|
afterEncode = convertor.ToRawUrlBase64(floatVal)
|
||||||
fmt.Println(afterEncode)
|
fmt.Println(afterEncode)
|
||||||
|
|
||||||
boolVal := true
|
boolVal := true
|
||||||
afterEncode = convertor.ToRawStdBase64(boolVal)
|
afterEncode = convertor.ToRawStdBase64(boolVal)
|
||||||
fmt.Println(afterEncode)
|
fmt.Println(afterEncode)
|
||||||
|
|
||||||
errVal := errors.New("err")
|
errVal := errors.New("err")
|
||||||
afterEncode = convertor.ToRawStdBase64(errVal)
|
afterEncode = convertor.ToRawStdBase64(errVal)
|
||||||
fmt.Println(afterEncode)
|
fmt.Println(afterEncode)
|
||||||
|
|
||||||
// Output:
|
// Output:
|
||||||
// aGVsbG8
|
// aGVsbG8
|
||||||
// aGVsbG8
|
// aGVsbG8
|
||||||
// MTIz
|
// MTIz
|
||||||
// eyJhIjoiaGkiLCJiIjoyLCJjIjp7IkEiOiJoZWxsbyIsIkIiOjN9fQ
|
// eyJhIjoiaGkiLCJiIjoyLCJjIjp7IkEiOiJoZWxsbyIsIkIiOjN9fQ
|
||||||
// MTIzLjQ1Ng
|
// MTIzLjQ1Ng
|
||||||
// dHJ1ZQ
|
// dHJ1ZQ
|
||||||
// ZXJy
|
// ZXJy
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@@ -599,6 +599,7 @@ func SubInBetween(str string, start string, end string) string {
|
|||||||
// HammingDistance calculates the Hamming distance between two strings.
|
// HammingDistance calculates the Hamming distance between two strings.
|
||||||
// The Hamming distance is the number of positions at which the corresponding symbols are different.
|
// The Hamming distance is the number of positions at which the corresponding symbols are different.
|
||||||
// This func returns an error if the input strings are of unequal lengths.
|
// This func returns an error if the input strings are of unequal lengths.
|
||||||
|
// Play: todo
|
||||||
func HammingDistance(a, b string) (int, error) {
|
func HammingDistance(a, b string) (int, error) {
|
||||||
if len(a) != len(b) {
|
if len(a) != len(b) {
|
||||||
return -1, errors.New("a length and b length are unequal")
|
return -1, errors.New("a length and b length are unequal")
|
||||||
|
|||||||
Reference in New Issue
Block a user