2
0
mirror of https://github.com/acepanel/panel.git synced 2026-02-04 09:13:49 +08:00
Files
panel/pkg/types/common.go
2024-10-11 02:56:28 +08:00

42 lines
714 B
Go

package types
type NV struct {
Name string `json:"name"`
Value string `json:"value"`
}
type KV struct {
Key string `json:"key"`
Value string `json:"value"`
}
type LV struct {
Label string `json:"label"`
Value string `json:"value"`
}
type LVInt struct {
Label string `json:"label"`
Value int `json:"value"`
}
// KVToMap 将 key-value 切片转换为 map
func KVToMap(kvs []KV) map[string]string {
m := make(map[string]string)
for _, item := range kvs {
m[item.Key] = item.Value
}
return m
}
// KVToSlice 将 key-value 切片转换为 key=value 切片
func KVToSlice(kvs []KV) []string {
var s []string
for _, item := range kvs {
s = append(s, item.Key+"="+item.Value)
}
return s
}