Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Vladimir Barsukov
zGo
Commits
6b3eeb2f
Commit
6b3eeb2f
authored
Jan 17, 2025
by
Vladimir Barsukov
Browse files
zbytes
parent
ad3568f1
Changes
1
Hide whitespace changes
Inline
Side-by-side
zbytes/zbytes.go
0 → 100644
View file @
6b3eeb2f
package
zbytes
import
(
"bytes"
"sync"
)
type
ZBuffer
struct
{
Buff
*
bytes
.
Buffer
Mu
*
sync
.
Mutex
}
func
NewBuffer
()
*
ZBuffer
{
return
&
ZBuffer
{
Buff
:
bytes
.
NewBuffer
(
nil
),
Mu
:
new
(
sync
.
Mutex
),
}
}
func
(
z
*
ZBuffer
)
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
)
{
z
.
Mu
.
Lock
()
defer
z
.
Mu
.
Unlock
()
return
z
.
Buff
.
WriteRune
(
r
)
}
func
(
z
*
ZBuffer
)
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
)
{
z
.
Mu
.
Lock
()
defer
z
.
Mu
.
Unlock
()
return
z
.
Buff
.
WriteString
(
s
)
}
func
(
z
*
ZBuffer
)
Bytes
()
[]
byte
{
z
.
Mu
.
Lock
()
defer
z
.
Mu
.
Unlock
()
return
z
.
Buff
.
Bytes
()
}
func
(
z
*
ZBuffer
)
String
()
string
{
z
.
Mu
.
Lock
()
defer
z
.
Mu
.
Unlock
()
return
z
.
Buff
.
String
()
}
func
(
z
*
ZBuffer
)
Reset
()
{
z
.
Mu
.
Lock
()
defer
z
.
Mu
.
Unlock
()
z
.
Buff
.
Reset
()
}
func
(
z
*
ZBuffer
)
Len
()
int
{
z
.
Mu
.
Lock
()
defer
z
.
Mu
.
Unlock
()
return
z
.
Buff
.
Len
()
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment