golang.org/x/playground@v0.0.0-20230418134305-14ebe15bcd59/examples/clear.txt (about)

     1  // Title: Clear
     2  package main
     3  
     4  import (
     5  	"fmt"
     6  	"strings"
     7  	"time"
     8  )
     9  
    10  func main() {
    11  	const col = 30
    12  	// Clear the screen by printing \x0c.
    13  	bar := fmt.Sprintf("\x0c[%%-%vs]", col)
    14  	for i := 0; i < col; i++ {
    15  		fmt.Printf(bar, strings.Repeat("=", i)+">")
    16  		time.Sleep(100 * time.Millisecond)
    17  	}
    18  	fmt.Printf(bar+" Done!", strings.Repeat("=", col))
    19  }