Files
kopia/internal/timetrack/timer.go
Jarek Kowalski 51dcaa985d chore(ci): upgraded linter to 1.48.0 (#2294)
Mechanically fixed all issues, added `lint-fix` make target.
2022-08-09 06:07:54 +00:00

22 lines
467 B
Go

// Package timetrack tracks the progress and estimates completion of a task.
package timetrack
import (
"time"
)
// Timer measures elapsed time of operations.
type Timer struct {
startTime time.Time
}
// Elapsed returns time elapsed since the timer was started.
func (t Timer) Elapsed() time.Duration {
return time.Since(t.startTime) //nolint:forbidigo
}
// StartTimer starts the timer.
func StartTimer() Timer {
return Timer{time.Now()} //nolint:forbidigo
}