From e29d27533725819ec3f6d05a27048d3d2627b53e Mon Sep 17 00:00:00 2001 From: Martin Fischer Date: Tue, 8 Apr 2025 19:25:36 +0200 Subject: refactor: port fetchers to Go * Austria: upgraded to RIS API v2.6 because v2.5 has been turned off --- lex-fetch/progress/progress.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 lex-fetch/progress/progress.go (limited to 'lex-fetch/progress') diff --git a/lex-fetch/progress/progress.go b/lex-fetch/progress/progress.go new file mode 100644 index 0000000..430d36e --- /dev/null +++ b/lex-fetch/progress/progress.go @@ -0,0 +1,27 @@ +package progress + +import ( + "fmt" + "io" + "sync" +) + +type Reporter struct { + Total int + cur int + mu sync.Mutex + writer io.Writer +} + +func NewReporter(writer io.Writer) Reporter { + return Reporter{writer: writer} +} + +func (r *Reporter) ReportProgress(num int) { + r.mu.Lock() + if num > r.cur { + fmt.Fprintf(r.writer, "%d/%d\n", num, r.Total) + r.cur = num + } + r.mu.Unlock() +} -- cgit v1.2.3