Clearing terminal screen in Go
Posted on 5 June, 2020
There are two ways I like (without any external dependency)
Using os/exec
package
os/exec
packageI have added some boilerplate code to make sure you see whats happening. I think this is probably the best way to do this.
Using ANSI Escape Sequences
Not a good way but may come in handy for some situations.
The sequence
\033[2J
is read as Esc[2J where "2j" clears the screen and moves the cursor to the home position (line 0, column 0).
Last updated