From bb5e771110baf19d2d68dee9e3e6ffa52d0c13c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20H=C3=BCbner?= Date: Sun, 26 May 2024 00:50:00 +0200 Subject: [PATCH] explicit empty type --- web/download/multi.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/web/download/multi.go b/web/download/multi.go index a584829..60006ee 100644 --- a/web/download/multi.go +++ b/web/download/multi.go @@ -24,15 +24,17 @@ type Downloader struct { Retries int } +type empty struct{} + func (g *Downloader) Download(baseDir string) { - semaphore := make(chan struct{}, g.Threads) // Create a semaphore to limit concurrency + semaphore := make(chan empty, g.Threads) // Create a semaphore to limit concurrency var wg sync.WaitGroup for i := range g.Downloads { wg.Add(1) dl := g.Downloads[i] - semaphore <- struct{}{} // Acquire a slot in the semaphore + semaphore <- empty{} // Acquire a slot in the semaphore go func() { defer func() { <-semaphore // Release the slot in the semaphore