I am iterating over an array and printing a formatted string with each array element to the terminal (stdout). Rather than printing each element on a new line, I want to overwrite the previous output with the program's newest output.
I am using macosx.
I have tried a few ways:
// 'f' is the current element of the array
b := bytes.NewBufferString("")
if err != nil {
fmt.Printf("Could not retrieve file info for %s
", f)
b.Reset()
} else {
fmt.Printf("Retrieved %s
", f)
b.Reset()
}
A second way was to remove from the string and add and additional Printf before each output:
fmt.Printf("\033[0;0H")
.