updated dependencies and go
This commit is contained in:
+5
-9
@@ -1,5 +1,7 @@
|
||||
package langext
|
||||
|
||||
import "maps"
|
||||
|
||||
import "encoding/json"
|
||||
|
||||
type MapEntry[T comparable, V any] struct {
|
||||
@@ -60,9 +62,7 @@ func MapToArr[T comparable, V any](v map[T]V) []MapEntry[T, V] {
|
||||
|
||||
func CopyMap[K comparable, V any](a map[K]V) map[K]V {
|
||||
result := make(map[K]V, len(a))
|
||||
for k, v := range a {
|
||||
result[k] = v
|
||||
}
|
||||
maps.Copy(result, a)
|
||||
return result
|
||||
}
|
||||
|
||||
@@ -90,14 +90,10 @@ func ForceJsonMapOrPanic(v any) map[string]any {
|
||||
func MapMerge[K comparable, V any](base map[K]V, arr ...map[K]V) map[K]V {
|
||||
res := make(map[K]V, len(base)*(1+len(arr)))
|
||||
|
||||
for k, v := range base {
|
||||
res[k] = v
|
||||
}
|
||||
maps.Copy(res, base)
|
||||
|
||||
for _, m := range arr {
|
||||
for k, v := range m {
|
||||
res[k] = v
|
||||
}
|
||||
maps.Copy(res, m)
|
||||
}
|
||||
|
||||
return res
|
||||
|
||||
Reference in New Issue
Block a user