35 lines
467 B
Go
35 lines
467 B
Go
package cosmovisor_test
|
|
|
|
import (
|
|
"bytes"
|
|
"sync"
|
|
)
|
|
|
|
// buffer is a thread safe bytes buffer
|
|
type buffer struct {
|
|
b bytes.Buffer
|
|
m sync.Mutex
|
|
}
|
|
|
|
func NewBuffer() *buffer {
|
|
return &buffer{}
|
|
}
|
|
|
|
func (b *buffer) Write(bz []byte) (int, error) {
|
|
b.m.Lock()
|
|
defer b.m.Unlock()
|
|
return b.b.Write(bz)
|
|
}
|
|
|
|
func (b *buffer) String() string {
|
|
b.m.Lock()
|
|
defer b.m.Unlock()
|
|
return b.b.String()
|
|
}
|
|
|
|
func (b *buffer) Reset() {
|
|
b.m.Lock()
|
|
defer b.m.Unlock()
|
|
b.b.Reset()
|
|
}
|