1
0
mirror of https://github.com/charlienet/go-mixed.git synced 2025-07-18 00:22:41 +08:00
This commit is contained in:
2022-05-12 10:33:35 +08:00
parent 3dc3fbb0f2
commit 7930a64e59
5 changed files with 43 additions and 18 deletions

View File

@ -40,10 +40,10 @@ func Merge[K comparable, V any](mm ...map[K]V) map[K]V {
// 按照键值生成字符串
func Join[K constraints.Ordered, V any](m Map[K, V], sep string, f func(k K, v V) string) string {
slice := make([]string, 0, m.Count())
for _, k := range m.Keys() {
v, _ := m.Get(k)
m.ForEach(func(k K, v V) {
slice = append(slice, f(k, v))
}
})
return strings.Join(slice, sep)
}