-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
I came across this issue while googling for something similar. As the readme in both projects says, these projects directly track the upstream internal package which the Go authors have decided they will not move to a non-internal path. @victorboissiere I assume you've already solved this issue but for anyone else who may stumble across this, this is easy to impliment yourself with a small function to color the diff:
func colorDiff(diffs string) string {
green := "\x1b[32m"
// green := "\x1b[48;5;194m" // if you prefer a light green background
red := "\x1b[31m"
// red := ""\x1b[48;5;210m" // if you prefer a light red/pink background
reset := "\x1b[0m" // Reset to default terminal colors
var colorDiff strings.Builder
lines := strings.Split(diffs, "\n")
for _, line := range lines {
if len(line) > 0 {
switch string(line[0]) {
case "-":
colorDiff.WriteString(red + line + reset + "\n")
case "+":
colorDiff.WriteString(green + line + reset + "\n")
default:
colorDiff.WriteString(line + "\n")
}
} else {
colorDiff.WriteString(line + "\n")
}
}
return colorDiff.String()
}Metadata
Metadata
Assignees
Labels
No labels