Created
February 20, 2019 09:35
-
-
Save Integralist/5b4c9489bf307da542d5f087adbbff42 to your computer and use it in GitHub Desktop.
[Golang Print over last line - like a counter] #go #golang #counter #inplace #print
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"time" | |
) | |
func main() { | |
ticker := time.Tick(time.Second) | |
for i := 1; i <= 10; i++ { | |
<-ticker | |
fmt.Printf("\x0cOn %d/10", i) | |
} | |
fmt.Println("\nAll is said and done.") | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"time" | |
) | |
func main() { | |
ticker := time.Tick(time.Second) | |
for i := 1; i <= 10; i++ { | |
<-ticker | |
fmt.Printf("\rOn %d/10", i) // escape sequence is different in this environment | |
} | |
fmt.Println("\nAll is said and done.") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Would it be possible to do this but instead of overwriting the line it scrolls up and places the text above the current bottom most line?
Im writing a telnet chat client in go and am having the issue of it overwriting my user input with chat messages.