1
0
mirror of https://github.com/charlienet/go-mixed.git synced 2025-07-18 00:22:41 +08:00
Files
go-mixed/structs/map_test.go
2022-04-29 17:18:27 +08:00

42 lines
831 B
Go

package structs_test
import (
"testing"
"github.com/charlienet/go-mixed/structs"
)
func TestStructToMap(t *testing.T) {
o := struct {
UserName string
InTagName string `json:"in_tag_name,omitempty"`
Ignore string `json:"-"`
KeepEmpty int
OmitEmpty int `json:",omitempty"`
}{
UserName: "测试字段",
InTagName: "具体名称",
Ignore: "这个字段跳过",
KeepEmpty: 0,
OmitEmpty: 0,
}
t.Log(structs.Struct2Map(o, structs.TagName("struct")))
t.Log(structs.Struct2Map(o, structs.IgnoreEmpty()))
t.Log(structs.Struct2Map(o, structs.Omitempty()))
t.Log(structs.Struct2Map(o, structs.Lcfirst()))
t.Log(structs.Struct2Map(o, structs.Camel2Case()))
}
func TestMapToStruct(t *testing.T) {
}
func TestMap2Map(t *testing.T) {
source := map[string]any{
"Abc": 143,
}
structs.New(source)
}