You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

65 lines
924 B

package state
type Setter struct {
K string
T int8 // 1 kv, 2 array, 3 slice, 4 map, 5 struct, 6 slice append
V any
Index int
K2 string
}
func SetArray(index int, v any) Setter {
return Setter{
T: 2,
V: v,
Index: index,
}
}
func SetSlice(index int, v any) Setter {
return Setter{
T: 3,
V: v,
Index: index,
}
}
func SetMap(k2 string, v any) Setter {
return Setter{
T: 4,
V: v,
K2: k2,
}
}
func SetStruct(k2 string, v any) Setter {
return Setter{
T: 5,
V: v,
K2: k2,
}
}
// SetSliceAppend 在元素结尾添加
func SetSliceAppend(v any) Setter {
return Setter{
T: 6,
V: v,
}
}
// SetSlicePopN 从结尾弹出n个元素
func SetSlicePopN(count int) Setter {
return Setter{
T: 7,
Index: count,
}
}
// SetSliceShiftN 从开头弹出n个元素
func SetSliceShiftN(count int) Setter {
return Setter{
T: 8,
Index: count,
}
}