gavv/httpexpect

Colorize diffs

Closed this issue · 2 comments

gavv commented

Follow-up for #161.

It would be nice to apply colorization when we format diffs:

  • color.FgWhite for lines starting with "---" and "+++"
  • color.FgGreen for lines starting with "+"
  • color.FgRed for lines staring with "-"
  • no color for other lines

Colorization should be implemented as a template function added to defaultTemplateFuncs, say, "colordiff", used as follows in defaultFailureTemplate:

{{ .Diff | colordiff | indent }}

This is needed because we don't want to pass colorized values to user templates, if user enabled custom templates.

Ralated: #334.

@gavv can I work on this one?

gavv commented

Sure, thanks!