Skip to content

Commit

Permalink
refactor: remove pointer from prefixed mutex
Browse files Browse the repository at this point in the history
  • Loading branch information
pd93 committed Dec 30, 2024
1 parent 0409c3c commit 8ce9bdc
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions internal/output/prefixed.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() }
}

Expand Down

0 comments on commit 8ce9bdc

Please sign in to comment.