@@ -198,18 +198,14 @@ func run() error {
198198 defer subCancel ()
199199 var wg sync.WaitGroup
200200
201- wg .Add (1 )
202- go func () {
203- defer wg .Done ()
201+ wg .Go (func () {
204202 blocklist .Run (subCtx , cfg .DisposableEmailBlocklistRefreshInterval )
205- }( )
203+ })
206204
207205 // The purge goroutine is started below after the attachment repository is initialised, because orphan attachment
208206 // cleanup needs access to the repo and storage provider.
209207 startPurgeGoroutine := func (attachRepo * attachment.PGRepository , storage media.StorageProvider ) {
210- wg .Add (1 )
211- go func () {
212- defer wg .Done ()
208+ wg .Go (func () {
213209 purgeExpiredData (subCtx , userRepo , attachRepo , storage , cfg )
214210
215211 ticker := time .NewTicker (cfg .DataCleanupInterval )
@@ -222,16 +218,14 @@ func run() error {
222218 purgeExpiredData (subCtx , userRepo , attachRepo , storage , cfg )
223219 }
224220 }
225- }( )
221+ })
226222 }
227223
228224 // Start permission cache invalidation subscriber with reconnection.
229225 permSub := permission .NewSubscriber (permCache , rdb , log .Logger )
230- wg .Add (1 )
231- go func () {
232- defer wg .Done ()
226+ wg .Go (func () {
233227 runWithBackoff (subCtx , "permission-cache-subscriber" , permSub .Run )
234- }( )
228+ })
235229
236230 // Load external templates from DATA_DIR (nil means use compiled-in defaults).
237231 verificationTmpl , verifyPageTmpl , err := loadTemplates (cfg .DataDir )
@@ -301,11 +295,9 @@ func run() error {
301295 // Start thumbnail worker with reconnection.
302296 thumbWorker := media .NewThumbnailWorker (rdb , storage , attachmentRepo , log .Logger )
303297 thumbWorker .EnsureStream (subCtx )
304- wg .Add (1 )
305- go func () {
306- defer wg .Done ()
298+ wg .Go (func () {
307299 runWithBackoff (subCtx , "thumbnail-worker" , thumbWorker .Run )
308- }( )
300+ })
309301 authService , err := auth .NewService (userRepo , rdb , cfg , blocklist , emailSender , serverRepo , permPublisher , log .Logger )
310302 if err != nil {
311303 return fmt .Errorf ("create auth service: %w" , err )
@@ -329,11 +321,9 @@ func run() error {
329321 DocumentStore : documentStore ,
330322 Logger : log .Logger ,
331323 })
332- wg .Add (1 )
333- go func () {
334- defer wg .Done ()
324+ wg .Go (func () {
335325 runWithBackoff (subCtx , "gateway-hub" , gatewayHub .Run )
336- }( )
326+ })
337327
338328 app := newFiberApp (cfg )
339329
@@ -704,11 +694,11 @@ func newFiberApp(cfg *config.Config) *fiber.App {
704694 // (e.g. Fiber's built-in 404/405). errors.AsType is a generic helper added in Go 1.26.
705695 ErrorHandler : func (c fiber.Ctx , err error ) error {
706696 status := fiber .StatusInternalServerError
707- message := "An internal error occurred"
697+ msg := "An internal error occurred"
708698 apiCode := apierrors .InternalError
709699 if e , ok := errors.AsType [* fiber.Error ](err ); ok {
710700 status = e .Code
711- message = e .Message
701+ msg = e .Message
712702 apiCode = fiberStatusToAPICode (e .Code )
713703 } else {
714704 log .Error ().Err (err ).
@@ -719,7 +709,7 @@ func newFiberApp(cfg *config.Config) *fiber.App {
719709 return c .Status (status ).JSON (httputil.ErrorResponse {
720710 Error : httputil.ErrorBody {
721711 Code : apiCode ,
722- Message : message ,
712+ Message : msg ,
723713 },
724714 })
725715 },
0 commit comments