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

fix

parent 6b3eeb2f
...@@ -5,57 +5,57 @@ import ( ...@@ -5,57 +5,57 @@ import (
"sync" "sync"
) )
type ZBuffer struct { type Buffer struct {
Buff *bytes.Buffer Buff *bytes.Buffer
Mu *sync.Mutex Mu *sync.Mutex
} }
func NewBuffer() *ZBuffer { func NewBuffer() *Buffer {
return &ZBuffer{ return &Buffer{
Buff: bytes.NewBuffer(nil), Buff: bytes.NewBuffer(nil),
Mu: new(sync.Mutex), 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() z.Mu.Lock()
defer z.Mu.Unlock() defer z.Mu.Unlock()
return z.Buff.Write(p) 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() z.Mu.Lock()
defer z.Mu.Unlock() defer z.Mu.Unlock()
return z.Buff.WriteRune(r) return z.Buff.WriteRune(r)
} }
func (z *ZBuffer) WriteByte(c byte) error { func (z *Buffer) WriteByte(c byte) error {
z.Mu.Lock() z.Mu.Lock()
z.Mu.Unlock() z.Mu.Unlock()
return z.Buff.WriteByte(c) 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() z.Mu.Lock()
defer z.Mu.Unlock() defer z.Mu.Unlock()
return z.Buff.WriteString(s) return z.Buff.WriteString(s)
} }
func (z *ZBuffer) Bytes() []byte { func (z *Buffer) Bytes() []byte {
z.Mu.Lock() z.Mu.Lock()
defer z.Mu.Unlock() defer z.Mu.Unlock()
return z.Buff.Bytes() return z.Buff.Bytes()
} }
func (z *ZBuffer) String() string { func (z *Buffer) String() string {
z.Mu.Lock() z.Mu.Lock()
defer z.Mu.Unlock() defer z.Mu.Unlock()
return z.Buff.String() return z.Buff.String()
} }
func (z *ZBuffer) Reset() { func (z *Buffer) Reset() {
z.Mu.Lock() z.Mu.Lock()
defer z.Mu.Unlock() defer z.Mu.Unlock()
z.Buff.Reset() z.Buff.Reset()
} }
func (z *ZBuffer) Len() int { func (z *Buffer) Len() int {
z.Mu.Lock() z.Mu.Lock()
defer z.Mu.Unlock() defer z.Mu.Unlock()
return z.Buff.Len() return z.Buff.Len()
......
...@@ -2,6 +2,7 @@ package zgo ...@@ -2,6 +2,7 @@ package zgo
import ( import (
_ "git.barsukov.pro/barsukov/zgo/zatomic" _ "git.barsukov.pro/barsukov/zgo/zatomic"
_ "git.barsukov.pro/barsukov/zgo/zbytes"
_ "git.barsukov.pro/barsukov/zgo/zcache" _ "git.barsukov.pro/barsukov/zgo/zcache"
_ "git.barsukov.pro/barsukov/zgo/zcron" _ "git.barsukov.pro/barsukov/zgo/zcron"
_ "git.barsukov.pro/barsukov/zgo/zdb" _ "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