Gotimeleft
It is used to know how much estimated time is left to finish a task.
Install / Use
/learn @jonathanhecl/GotimeleftREADME
GoTimeLeft
A lightweight Go library for estimating time remaining for tasks and displaying progress bars in command-line applications.
Features
- 🚀 Accurate time estimation using weighted moving averages
- 📊 Multiple progress visualization options
- ⚡ Lightweight and dependency-free
- 🛠️ Simple and intuitive API
- 📈 Handles progress tracking for tasks of any size
- 🎨 Customizable progress bar display
Installation
go get github.com/jonathanhecl/gotimeleft
Quick Start
package main
import (
"fmt"
"time"
"github.com/jonathanhecl/gotimeleft"
)
func main() {
// Initialize with total number of items
tl := gotimeleft.Init(100)
// Simulate work
for i := 0; i <= 100; i++ {
time.Sleep(50 * time.Millisecond)
// Update progress (either by step or value)
tl.Step(1)
// or: tl.Value(i)
// Display progress
fmt.Printf("\r%s %s %s",
tl.GetProgressBar(30),
tl.GetProgress(1),
tl.GetTimeLeft().Round(time.Second),
)
}
}
Usage Examples
Basic Progress Tracking
tl := gotimeleft.Init(1000) // Initialize with total items
// Update progress
tl.Step(10) // Increment by 10
// or
tl.Value(100) // Set absolute value
// Get current progress
progress := tl.GetFloat64() // 0.1 (10%)
Displaying Progress
// Get progress bar (30 characters wide)
progressBar := tl.GetProgressBar(30) // [=========>...................]
// Get percentage
percentage := tl.GetProgress(2) // "10.50%"
// Get values as string
values := tl.GetProgressValues() // "100/1000"
Time Estimation
// Get time left
timeLeft := tl.GetTimeLeft() // 1h30m45s
// Get time spent
timeSpent := tl.GetTimeSpent() // 45m12s
// Get operations per second
opsPerSec := tl.GetPerSecond() // 123.45
Advanced Configuration
Customizing Progress Bar
// Get a progress bar with custom width (e.g., 50 characters)
bar := tl.GetProgressBar(50)
// The progress bar will look like:
// [======================>.................................] 45.0%
Resetting Progress
// Reset with new total
tl.Reset(200)
Best Practices
- Initialize Early: Create the TimeLeft instance before starting your task
- Update Frequently: Call Step() or Value() regularly for accurate time estimation
- Handle Completion: Check if progress reaches 100% to handle task completion
- Use Appropriate Precision: Choose the right decimal places for your progress display
Performance
GoTimeLeft is designed to be efficient with minimal overhead. The time estimation algorithm uses a weighted moving average to provide smooth and accurate predictions.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Example Output
[========================>......................] 45.0% 12.5s

Author
Jonathan Hecl
⭐ If you find this project useful, please consider giving it a star on GitHub!
timeleft := gotimeleft.Init(100) // Total 100, value 0
...
timeleft.Reset(200) // Reset to total 200, value 0
...
timeleft.Step(10) // value +10
...
timeleft.Value(50) // value 50
...
timeleft.GetProgressValues() // => 55/100 string
timeleft.GetProgress(2) // => 55.33% string with 2 decimals
timeleft.GetProgressBar(30) // [==============>...............] string with 30 chars
timeleft.GetFloat64() // => 0.55 float64
timeleft.GetPerSecond() // => 5.55 float64 per second
timeleft.GetTimeLeft() // => 0.5ms time.Duration
timeleft.GetTimeSpent() // => 2s time.Duration
Related Skills
node-connect
351.8kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
xurl
351.8kA CLI tool for making authenticated requests to the X (Twitter) API. Use this skill when you need to post tweets, reply, quote, search, read posts, manage followers, send DMs, upload media, or interact with any X API v2 endpoint.
frontend-design
110.9kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
351.8kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
