(d Diff, path []interface{}, long bool)
| 109 | } |
| 110 | |
| 111 | func formatSub(d Diff, path []interface{}, long bool) string { |
| 112 | // Format the element |
| 113 | formatted := formatDiff(d, path, long) |
| 114 | |
| 115 | v, isValue := d.(value) |
| 116 | if isValue { |
| 117 | k := reflect.ValueOf(v.Value()).Kind() |
| 118 | |
| 119 | if k != reflect.Array && k != reflect.Map && k != reflect.Slice { |
| 120 | return fmt.Sprintf(" %s\n", formatted) |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | // Trim out blank lines |
| 125 | parts := make([]string, 0) |
| 126 | for _, part := range strings.Split(formatted, "\n") { |
| 127 | if strings.TrimSpace(part) != "" { |
| 128 | parts = append(parts, part) |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | output := strings.Builder{} |
| 133 | |
| 134 | output.WriteString("\n") |
| 135 | for _, part := range parts { |
| 136 | if isValue { |
| 137 | part = fmt.Sprintf("%s %s%s", v.Mode(), indent, part) |
| 138 | } else { |
| 139 | part = part[:len(Added.String())] + indent + part[len(Added.String()):] |
| 140 | } |
| 141 | |
| 142 | output.WriteString(part) |
| 143 | output.WriteString("\n") |
| 144 | } |
| 145 | |
| 146 | return output.String() |
| 147 | } |
no test coverage detected