]> git.giacomolli.uk - onechat/blob - sync_buffer_helper_test.go
Check the width of comment lines
[onechat] / sync_buffer_helper_test.go
1 package main
2
3 import (
4 "bytes"
5 "sync"
6 )
7
8 // SyncBuffer is a buffer that the test and the client use at once.
9 type SyncBuffer struct {
10 mutex sync.Mutex
11 buffer bytes.Buffer
12 }
13
14 func (b *SyncBuffer) Write(p []byte) (int, error) {
15 b.mutex.Lock()
16 defer b.mutex.Unlock()
17
18 return b.buffer.Write(p)
19 }
20
21 func (b *SyncBuffer) String() string {
22 b.mutex.Lock()
23 defer b.mutex.Unlock()
24
25 return b.buffer.String()
26 }