(offset string, header string, oldMap map[string]string, newMap map[string]string)
| 108 | } |
| 109 | |
| 110 | func (ui UI) displayDiffForMapStringString(offset string, header string, oldMap map[string]string, newMap map[string]string) { |
| 111 | var oldKeys []string |
| 112 | for key := range oldMap { |
| 113 | oldKeys = append(oldKeys, key) |
| 114 | } |
| 115 | |
| 116 | var newKeys []string |
| 117 | for key := range newMap { |
| 118 | newKeys = append(newKeys, key) |
| 119 | } |
| 120 | |
| 121 | sortedKeys := sortedUniqueArray(oldKeys, newKeys) |
| 122 | |
| 123 | fmt.Fprintf(ui.Out, " %s\n", ui.TranslateText(header)) |
| 124 | for _, key := range sortedKeys { |
| 125 | newVal, ok := newMap[key] |
| 126 | if !ok { |
| 127 | formattedOld := fmt.Sprintf("- %s", key) |
| 128 | fmt.Fprintln(ui.Out, ui.modifyColor(formattedOld, color.New(color.FgRed))) |
| 129 | continue |
| 130 | } |
| 131 | oldVal, ok := oldMap[key] |
| 132 | if !ok { |
| 133 | formattedNew := fmt.Sprintf("+ %s", key) |
| 134 | fmt.Fprintln(ui.Out, ui.modifyColor(formattedNew, color.New(color.FgGreen))) |
| 135 | continue |
| 136 | } |
| 137 | |
| 138 | if oldVal == newVal { |
| 139 | fmt.Fprintf(ui.Out, " %s\n", key) |
| 140 | } else { |
| 141 | formattedOld := fmt.Sprintf("- %s", key) |
| 142 | fmt.Fprintln(ui.Out, ui.modifyColor(formattedOld, color.New(color.FgRed))) |
| 143 | formattedNew := fmt.Sprintf("+ %s", key) |
| 144 | fmt.Fprintln(ui.Out, ui.modifyColor(formattedNew, color.New(color.FgGreen))) |
| 145 | } |
| 146 | } |
| 147 | } |
| 148 | |
| 149 | func (ui UI) displayDiffForNullInt(offset string, header string, oldValue types.NullInt, newValue types.NullInt) { |
| 150 | if oldValue != newValue { |
no test coverage detected