Home > Blockchain >  How do I clear the terminal screen down from my cursor position?
How do I clear the terminal screen down from my cursor position?

Time:11-10

In nodejs, I can clear my screen down with <WriteStream>.clearScreenDown(), i.e., process.stdout.clearScreenDown().

How would I achieve this in go?

I assume I need an ansi escape code, but I can not find any for this problem.

I have tried \033[2J, but the clears the entire screen. I only want to clear the screen down from my current cursor position.

import "fmt"

func main() {
    fmt.Printf("?")
}

CodePudding user response:

\033[2J was the right start, just need to replace the 2 with a 0.

import "fmt"

func main() {
    fmt.Print("\033[0J")
}
  • Related