summaryrefslogtreecommitdiff
path: root/lex-fetch/progress
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2025-04-08 19:25:36 +0200
committerMartin Fischer <martin@push-f.com>2025-04-14 07:04:45 +0200
commite29d27533725819ec3f6d05a27048d3d2627b53e (patch)
tree5afba50408b25179edb4ea6445acfe1d3e051488 /lex-fetch/progress
parent96236c9d80cea2d6ba83591a7d08a8cc096fd8d3 (diff)
refactor: port fetchers to Go
* Austria: upgraded to RIS API v2.6 because v2.5 has been turned off
Diffstat (limited to 'lex-fetch/progress')
-rw-r--r--lex-fetch/progress/progress.go27
1 files changed, 27 insertions, 0 deletions
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()
+}