Commit a3eb6d40 authored by Vladimir Barsukov's avatar Vladimir Barsukov
Browse files

fix

parent 6b3eeb2f
......@@ -5,57 +5,57 @@ import (
"sync"
)
type ZBuffer struct {
type Buffer struct {
Buff *bytes.Buffer
Mu *sync.Mutex
}
func NewBuffer() *ZBuffer {
return &ZBuffer{
func NewBuffer() *Buffer {
return &Buffer{
Buff: bytes.NewBuffer(nil),
Mu: new(sync.Mutex),
}
}
func (z *ZBuffer) Write(p []byte) (n int, err error) {
func (z *Buffer) Write(p []byte) (n int, err error) {
z.Mu.Lock()
defer z.Mu.Unlock()
return z.Buff.Write(p)
}
func (z *ZBuffer) WriteRune(r rune) (n int, err error) {
func (z *Buffer) WriteRune(r rune) (n int, err error) {
z.Mu.Lock()
defer z.Mu.Unlock()
return z.Buff.WriteRune(r)
}
func (z *ZBuffer) WriteByte(c byte) error {
func (z *Buffer) WriteByte(c byte) error {
z.Mu.Lock()
z.Mu.Unlock()
return z.Buff.WriteByte(c)
}
func (z *ZBuffer) WriteString(s string) (n int, err error) {
func (z *Buffer) WriteString(s string) (n int, err error) {
z.Mu.Lock()
defer z.Mu.Unlock()
return z.Buff.WriteString(s)
}
func (z *ZBuffer) Bytes() []byte {
func (z *Buffer) Bytes() []byte {
z.Mu.Lock()
defer z.Mu.Unlock()
return z.Buff.Bytes()
}
func (z *ZBuffer) String() string {
func (z *Buffer) String() string {
z.Mu.Lock()
defer z.Mu.Unlock()
return z.Buff.String()
}
func (z *ZBuffer) Reset() {
func (z *Buffer) Reset() {
z.Mu.Lock()
defer z.Mu.Unlock()
z.Buff.Reset()
}
func (z *ZBuffer) Len() int {
func (z *Buffer) Len() int {
z.Mu.Lock()
defer z.Mu.Unlock()
return z.Buff.Len()
......
......@@ -2,6 +2,7 @@ package zgo
import (
_ "git.barsukov.pro/barsukov/zgo/zatomic"
_ "git.barsukov.pro/barsukov/zgo/zbytes"
_ "git.barsukov.pro/barsukov/zgo/zcache"
_ "git.barsukov.pro/barsukov/zgo/zcron"
_ "git.barsukov.pro/barsukov/zgo/zdb"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment