excludeMapKeys creates a new map excluding the specified keys
(original map[string]any, excludeKeys ...string)
| 41 | |
| 42 | // excludeMapKeys creates a new map excluding the specified keys |
| 43 | func excludeMapKeys(original map[string]any, excludeKeys ...string) map[string]any { |
| 44 | if mapHelpersLog.Enabled() { |
| 45 | mapHelpersLog.Printf("excludeMapKeys: input=%d keys, excluding=%v", len(original), excludeKeys) |
| 46 | } |
| 47 | excludeSet := make(map[string]struct { |
| 48 | }) |
| 49 | for _, key := range excludeKeys { |
| 50 | excludeSet[key] = struct { |
| 51 | }{} |
| 52 | } |
| 53 | |
| 54 | result := make(map[string]any) |
| 55 | for key, value := range original { |
| 56 | if !setutil.Contains(excludeSet, key) { |
| 57 | result[key] = value |
| 58 | } |
| 59 | } |
| 60 | if mapHelpersLog.Enabled() { |
| 61 | mapHelpersLog.Printf("excludeMapKeys: output=%d keys", len(result)) |
| 62 | } |
| 63 | return result |
| 64 | } |