{"id":28762382,"url":"https://github.com/fortio/progressbar","last_synced_at":"2025-06-17T08:08:27.142Z","repository":{"id":281085813,"uuid":"944152460","full_name":"fortio/progressbar","owner":"fortio","description":"Zero dependency golang progress bar for terminal/CLIs","archived":false,"fork":false,"pushed_at":"2025-04-18T22:59:58.000Z","size":295,"stargazers_count":17,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-05-02T09:12:36.950Z","etag":null,"topics":["examples","golang-library","progress-bar","progressbar","tui","zero-dependency"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fortio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-03-06T21:47:56.000Z","updated_at":"2025-04-24T14:31:54.000Z","dependencies_parsed_at":null,"dependency_job_id":"b8b5a429-b6de-4c56-b1d4-4acb63129a4d","html_url":"https://github.com/fortio/progressbar","commit_stats":null,"previous_names":["fortio/progressbar"],"tags_count":18,"template":false,"template_full_name":null,"purl":"pkg:github/fortio/progressbar","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fortio%2Fprogressbar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fortio%2Fprogressbar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fortio%2Fprogressbar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fortio%2Fprogressbar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fortio","download_url":"https://codeload.github.com/fortio/progressbar/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fortio%2Fprogressbar/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260318707,"owners_count":22991122,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["examples","golang-library","progress-bar","progressbar","tui","zero-dependency"],"created_at":"2025-06-17T08:08:26.545Z","updated_at":"2025-06-17T08:08:27.122Z","avatar_url":"https://github.com/fortio.png","language":"Go","readme":"# progressbar\n[![GoDoc](https://godoc.org/fortio.org/progressbar?status.svg)](https://pkg.go.dev/fortio.org/progressbar)\n[![Go Report Card](https://goreportcard.com/badge/fortio.org/progressbar)](https://goreportcard.com/report/fortio.org/progressbar)\n[![CI Checks](https://github.com/fortio/progressbar/actions/workflows/include.yml/badge.svg)](https://github.com/fortio/progressbar/actions/workflows/include.yml)\n[![GitHub Release](https://img.shields.io/github/release/fortio/progressbar.svg?style=flat)](https://github.com/fortio/progressbar/releases/)\n\n\nZero dependency cross platform (just needs basic ANSI codes and Unicode font support,\nand ANSI codes can be disabled too if needed) golang concurrent safe progress bar for terminal/CLIs, with 8x the resolution of others (8 steps per character).\n\nShows a spinner and/or a progress bar with optional prefix and extra info.\n\nAlso provides reader/writer wrappers to automatically show progress of downloads/uploads\nor other io operations, as well as a Writer that can be used concurrently with the progress bar to show other output on screen.\n\n## Examples\n\nSee [examples/](examples/)\n\n### Manually updating a progress bar and additional output\n\nManually handling a 2-line output update (1 misc line and the 1 line for the progress bar):\n\n```go\n\tpb := progressbar.NewBar()\n\tfmt.Print(\"Progress bar example\\n\\n\") // 1 empty line before the progress bar, for the demo\n\tn := 1000\n\tfor i := 0; i \u003c= n; i++ {\n\t\tpb.ProgressBar(100. * float64(i) / float64(n))\n\t\tif i%63 == 0 {\n\t\t\tprogressbar.MoveCursorUp(1)\n\t\t\tfmt.Printf(\"Just an extra demo print for %d\\n\", i)\n\t\t}\n\t\ttime.Sleep(20 * time.Millisecond)\n\t}\n```\n\nSource: [examples/simple/simple.go](examples/simple/example.go) (`-moveup` mode)\n\n### Concurrent safe screen writer example\n\n```go\n\tpb := progressbar.NewBar()\n\tw := pb.Writer()\n\tfmt.Fprintln(w, \"Progress bar example\")\n\t// demonstrate concurrency safety:\n\tgo PrintStuff(w, *everyFlag)\n\t// exact number of 'pixels', just to demo every smooth step:\n\tn := pb.Width * 8\n\tfor i := 0; i \u003c= n; i++ {\n\t\tpb.ProgressBar(100. * float64(i) / float64(n))\n\t\ttime.Sleep(*delayFlag)\n\t}\n```\n\n```sh\ngo run fortio.org/progressbar/examples/simple@latest -color\n```\n\nProduces\n\n![Example Screenshot](example.png)\n\nOr without color:\n```\n◅███████████████████████████▊            ▻ 69.4%\n```\n\nSource: [examples/simple/example.go](examples/simple/example.go) (default mode)\n\n### Automatic Reader or Writer progress bar\n\n```go\n\treader := progressbar.NewAutoReader(progressbar.NewBar(), resp.Body, resp.ContentLength)\n\t_, err = io.Copy(os.Stdout, reader)\n\treader.Close()\n```\n\nSee it in action with a progress bar while downloading a URL:\n```sh\ngo run fortio.org/progressbar/examples/auto@latest https://go.dev/ \u003e go_dev.html\n```\n\nWill show a progress bar for instance\n```\n$  go run ./examples/auto https://go.dev/dl/go1.24.1.src.tar.gz \u003e /dev/null\nFetching https://go.dev/dl/go1.24.1.src.tar.gz\n⣾ █████████████████████▌                   53.7% 15.766 Mb out of 29.352 Mb, 293ms elapsed, 53.790 Mb/s, 253ms remaining\n```\n\nSource (now includes a multi bar separating R/W): [auto_examples/auto/auto_example.go](auto_examples/auto/auto_example.go)\n\n\n### Multiple Bars updating concurrently\n```go\n\tcfg := progressbar.DefaultConfig()\n\tcfg.ExtraLines = 1\n\tcfg.ScreenWriter = os.Stdout\n\tmbar := cfg.NewMultiBarPrefixes(\n\t\t\"b1\",\n\t\t\"longest prefix\",\n\t\t\"short\",\n\t\t\"b4\",\n\t)\n\twg := sync.WaitGroup{}\n\tfor i, bar := range mbar {\n\t\twg.Add(1)\n\t\t// Update at random speed so bars move differently for a demo:\n\t\tdelay := time.Duration(5+rand.IntN(40)) * time.Millisecond\n\t\tbar.WriteAbove(fmt.Sprintf(\"\\t\\t\\tBar %d delay is %v\", i+1, delay))\n\t\tgo func(b *progressbar.State) {\n\t\t\tUpdateBar(b, delay)\n\t\t\twg.Done()\n\t\t}(bar)\n\t}\n\twg.Wait()\n\tprogressbar.MultiBarEnd(mbar)\n```\n\n![Multi example Screenshot](multi.png)\n\nComplete source: [multi_example/multi_example.go](multi_example/multi_example.go)\n\nWhich includes adding extra bars dynamically.\n\n### Multicurl\nYou can see it in use in [fortio/multicurl](https://github.com/fortio/multicurl?tab=readme-ov-file#multicurl) cli too.\n\n## See also\n\nIf you have more advanced needs for TUI including raw mode input or readline, you can also see/use/have a look at\n\n[github.com/fortio/terminal](https://github.com/fortio/terminal#terminal)\n\nAnd still use this for a progress bar part.\n\nIt is used for instance in [github.com/fortio/fps's web mode progress update](https://github.com/fortio/fps#web-serving-fire-mode)\n\nAnd [grol](https://github.com/grol-io/grol#grol)'s multi file processing progress info (`make grol-tests`)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffortio%2Fprogressbar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffortio%2Fprogressbar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffortio%2Fprogressbar/lists"}