Skip to content

Commit

Permalink
Refactor output writer implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
suntala committed Feb 12, 2025
1 parent 59f309a commit 8a61785
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/testing/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -1009,12 +1009,12 @@ func (c *common) log(s string) {
if l := len(s); l > 0 && (string(s[l-1]) != "\n") {
s += "\n"
}
cs := c.getCallSite(3) // getCallSite + log + public function
cs := c.callSite(3) // callSite + log + public function
c.newOutputWriter(cs).Write([]byte(s))
}

// getCallSite retrieves and formats the file and line of the call site.
func (c *common) getCallSite(skip int) string {
// callSite retrieves and formats the file and line of the call site.
func (c *common) callSite(skip int) string {
c.mu.Lock()
defer c.mu.Unlock()

Expand All @@ -1039,8 +1039,7 @@ func (c *common) getCallSite(skip int) string {

// newOutputWriter initialises a new outputWriter with the provided call site.
func (c *common) newOutputWriter(cs string) io.Writer {
b := make([]byte, 0)
return &outputWriter{c, b, cs}
return &outputWriter{c, nil, cs}
}

// outputWriter buffers, formats and writes input.
Expand Down

0 comments on commit 8a61785

Please sign in to comment.