
Security News
npm Adopts OIDC for Trusted Publishing in CI/CD Workflows
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
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.
Security News
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.