
Product
Announcing Precomputed Reachability Analysis in Socket
Socket’s precomputed reachability slashes false positives by flagging up to 80% of vulnerabilities as irrelevant, with no setup and instant results.
github.com/rodrigopetter/go-progress-bar
A simple progress bar implementation for Go applications with support for nested progress bars, stages, and logging integration.
go get github.com/RodrigoPetter/go-progress-bar
package main
import (
"time"
progressbar "github.com/RodrigoPetter/go-progress-bar"
)
func main() {
// Create a new progress bar
bar := progressbar.NewProgressBar("Main Task")
// Start the render loop
progressbar.StartRenderLoop(bar)
// Update progress
for i := 0; i <= 100; i++ {
bar.Increment(1)
time.Sleep(100 * time.Millisecond)
}
// Mark as complete
bar.Finish()
}
This code will output the following bar:
⠦[00:00:03] - Main Task - [35% ##### ]
func main() {
mainBar := progressbar.NewProgressBar("Main Task")
subBar1 := mainBar.NewSubBar("Subtask 1")
subBar2 := mainBar.NewSubBar("Subtask 2")
progressbar.StartRenderLoop(mainBar)
// Update progress for different bars
for i := 0; i <= 100; i++ {
mainBar.Increment(1)
subBar1.Increment(2)
subBar2.Increment(1)
time.Sleep(100 * time.Millisecond)
}
}
This code will output the following bar:
⠴[00:00:03] - Main Task - [30% #### ]
⠴[00:00:03] - Subtask 1 - [60% ###### ]
⠴[00:00:03] - Subtask 2 - [30% ### ]
func main() {
// Create a progress bar with 5 stages
bar := progressbar.NewProgressBar("Stage Progress",
progressbar.WithStages(5))
progressbar.StartRenderLoop(bar)
// Progress through stages
for i := 0; i < 5; i++ {
time.Sleep(1 * time.Second)
bar.Increment(1)
}
}
This code will output the following bar:
⠦[00:00:03] Stage 3/5 - Stage Progress - [60% ############## ]
This feature prevents log messages from breaking the progress bar's visual display. Without this integration, log messages would interrupt and corrupt the progress bar's appearance in the terminal.
func main() {
bar := progressbar.NewProgressBar("Task with Logs")
// Configure the log writer
// Ensures logs work harmoniously with the progress bar
log.SetOutput(bar.GetLogWriter())
progressbar.StartRenderLoop(bar)
// Logs will be displayed alongside the progress bar
log.Println("Starting process...")
for i := 0; i <= 100; i++ {
bar.Increment(1)
if i%20 == 0 {
log.Printf("Completed %d%%", i)
}
time.Sleep(100 * time.Millisecond)
}
log.Println("Process completed!")
}
This code will output the following bar:
2025/04/21 17:05:56 Starting process...
2025/04/21 17:05:56 Completed 0%
2025/04/21 17:05:58 Completed 20%
2025/04/21 17:06:00 Completed 40%
⠋[00:00:05] - Task with Logs - [55% ################## ]
The progress bar can be customized using various options:
bar := goprogressbar.NewProgressBar("Custom Bar",
goprogressbar.WithMaxProgress(200), // Set custom max progress
goprogressbar.WithStages(5), // Use stage-based progress
)
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket’s precomputed reachability slashes false positives by flagging up to 80% of vulnerabilities as irrelevant, with no setup and instant results.
Product
Socket is launching experimental protection for Chrome extensions, scanning for malware and risky permissions to prevent silent supply chain attacks.
Product
Add secure dependency scanning to Claude Desktop with Socket MCP, a one-click extension that keeps your coding conversations safe from malicious packages.