[go-nuts] Re: Is it possible to change the existing printline dynamically in golang?

2022-04-11 Thread Zhaoxun Yan
Thanks a log Amnon! :D

在2022年4月1日星期五 UTC+8 21:25:14 写道:

> 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 写道:
>>
>>> 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/cb9fdc0b-fc25-4b7b-b53b-1377f906829dn%40googlegroups.com.


[go-nuts] Re: Is it possible to change the existing printline dynamically in golang?

2022-04-01 Thread Amnon
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 写道:
>
>> 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.


[go-nuts] Re: Is it possible to change the existing printline dynamically in golang?

2022-04-01 Thread Zhaoxun Yan
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 写道:

> 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/702dad6d-006f-47b5-94d5-ca231b0245fcn%40googlegroups.com.


[go-nuts] Re: Is it possible to change the existing printline dynamically in golang?

2022-04-01 Thread 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/80dd0cbc-7bbb-4453-8e23-e8dc6f37bb4bn%40googlegroups.com.