From fa8a997395fe449080e1aeab2d655bf2f75f9b2c Mon Sep 17 00:00:00 2001 From: raul Date: Wed, 21 Feb 2024 18:07:30 +0100 Subject: [PATCH] Added loading-bar exercise --- loading-bar/go.mod | 3 +++ loading-bar/main.go | 14 ++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 loading-bar/go.mod create mode 100644 loading-bar/main.go diff --git a/loading-bar/go.mod b/loading-bar/go.mod new file mode 100644 index 0000000..900e50d --- /dev/null +++ b/loading-bar/go.mod @@ -0,0 +1,3 @@ +module loading-bar + +go 1.22.0 diff --git a/loading-bar/main.go b/loading-bar/main.go new file mode 100644 index 0000000..a8dc24c --- /dev/null +++ b/loading-bar/main.go @@ -0,0 +1,14 @@ +package main + +import ( + "fmt" + "time" +) + +func main() { + for i := 0; i < 101; i++ { + fmt.Printf("\rLoading... %v%%", i) + time.Sleep(50 * time.Millisecond) + } + fmt.Printf("\n") +}