Yes, this is the murky world of ANSI escape codes. Fortunately there are a whole load of libraries which do this for you... Try https://github.com/cheggaaa/pb or https://github.com/schollz/progressbar or github.com/vardius/progress-go
On Friday, 1 April 2022 at 13:12:11 UTC+1 yan.z...@gmail.com wrote: > Got it: > > package main > > import( > "fmt" > "time" > ) > > func main() { > fmt.Printf("Hello") > time.Sleep(time.Second) > time.Sleep(time.Second) > fmt.Printf("\r") > fmt.Printf("World\n") > } > > 在2022年4月1日星期五 UTC+8 15:34:08<Henry> 写道: > >> You can use the ansi escape code if the target terminal supports it. >> Alternatively, you can use the carriage return '\r' and reprint the line. >> Note you may need to overwrite with empty space to delete the line before >> rewriting it. >> >> On Friday, April 1, 2022 at 12:38:37 PM UTC+7 yan.z...@gmail.com wrote: >> >>> I just noticed how python pip upgraded from printing numerous process >>> bars like this: >>> ■■■ 30% completed >>> ■■■■ 40% completed >>> ■■■■■■ 60% completed >>> ■■■■■■■■ 80% completed >>> ■■■■■■■■■■ 100% completed >>> >>> to a single line of a growing bar and changing declaration. >>> >>> It is definitely a functionality that prompts of both Linux and Windows >>> allows - >>> To change the previous print line. >>> Is it possible to realize this in golang? >>> >>> Zhaoxun >>> >> -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/47ad2497-6a3a-4aae-9559-5f3fd0bac808n%40googlegroups.com.