Skip to content

Instantly share code, notes, and snippets.

@austintraver
Created March 10, 2021 23:07
Show Gist options
  • Select an option

  • Save austintraver/b1efb8125ded85cc079dd40f7d5f911f to your computer and use it in GitHub Desktop.

Select an option

Save austintraver/b1efb8125ded85cc079dd40f7d5f911f to your computer and use it in GitHub Desktop.
A colorful loading bar, written in Go
package main
import "fmt"
import "time"
import "strconv"
import "strings"
func loading() {
for {
fmt.Printf("\n\x1b[2F\x1b[1BLoading... ")
time.Sleep(100 * time.Millisecond)
for i := 1; i < 7; i += 1 {
format := "\x1b[12`\x1b[1;3" + strconv.Itoa(i) + "m" + strings.Repeat("*", i) + "\x1b[0m"
fmt.Printf(format)
time.Sleep(250 * time.Millisecond)
}
// fmt.Printf("\x1b[12`\x1b[1;37m" + " " + "\x1b[0m")
time.Sleep(250 * time.Millisecond)
}
}
func main() {
go loading()
time.Sleep(time.Second * 5)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment