From 8ce9bdc8c7711b68174c463f3205bd98de15fa70 Mon Sep 17 00:00:00 2001 From: Pete Davison Date: Mon, 30 Dec 2024 18:03:29 +0000 Subject: [PATCH] refactor: remove pointer from prefixed mutex --- internal/output/prefixed.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/internal/output/prefixed.go b/internal/output/prefixed.go index 68d941563e..fd2a230570 100644 --- a/internal/output/prefixed.go +++ b/internal/output/prefixed.go @@ -15,22 +15,21 @@ type Prefixed struct { logger *logger.Logger seen map[string]uint counter *uint - mutex *sync.Mutex + mutex sync.Mutex } -func NewPrefixed(logger *logger.Logger) Prefixed { +func NewPrefixed(logger *logger.Logger) *Prefixed { var counter uint - return Prefixed{ + return &Prefixed{ seen: make(map[string]uint), counter: &counter, logger: logger, - mutex: &sync.Mutex{}, } } -func (p Prefixed) WrapWriter(stdOut, _ io.Writer, prefix string, _ *templater.Cache) (io.Writer, io.Writer, CloseFunc) { - pw := &prefixWriter{writer: stdOut, prefix: prefix, prefixed: &p} +func (p *Prefixed) WrapWriter(stdOut, _ io.Writer, prefix string, _ *templater.Cache) (io.Writer, io.Writer, CloseFunc) { + pw := &prefixWriter{writer: stdOut, prefix: prefix, prefixed: p} return pw, pw, func(error) error { return pw.close() } }