2024-05-06 14:56:35 +08:00
|
|
|
// Package wrapper ...
|
|
|
|
//
|
|
|
|
// Description : wrapper ...
|
|
|
|
//
|
|
|
|
// Author : go_developer@163.com<白茶清欢>
|
|
|
|
//
|
|
|
|
// Date : 2024-05-06 下午2:48
|
|
|
|
package wrapper
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestArray_Unique(t *testing.T) {
|
2024-08-06 16:03:12 +08:00
|
|
|
fmt.Println(ArrayType[any, any]([]any{"1", 1, 1, "1", 2, 3}).Unique())
|
|
|
|
fmt.Println(ArrayType[int, any]([]int{1, 1, 2, 3}).Unique())
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestArray_ExtractField(t *testing.T) {
|
|
|
|
testMap := []any{
|
|
|
|
map[string]any{
|
|
|
|
"age": 18,
|
|
|
|
"name": "baicha",
|
|
|
|
},
|
|
|
|
map[string]any{
|
|
|
|
"age": 20,
|
|
|
|
"name": "qinghuan",
|
|
|
|
},
|
|
|
|
map[string]any{
|
|
|
|
"foo": "bar",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
fmt.Println(ArrayType[any, int](testMap).ExtractField("age"))
|
|
|
|
fmt.Println(ArrayType[any, string](testMap).ExtractField("name"))
|
2024-05-06 14:56:35 +08:00
|
|
|
}
|