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
bbdb2ba8
Commit
bbdb2ba8
authored
Feb 03, 2025
by
Vladimir Barsukov
Browse files
add lock/unlock
parent
9a2dfae3
Changes
1
Hide whitespace changes
Inline
Side-by-side
zbytes/zbytes.go
View file @
bbdb2ba8
...
...
@@ -2,6 +2,7 @@ package zbytes
import
(
"bytes"
"fmt"
"sync"
)
...
...
@@ -41,6 +42,9 @@ func (z *Buffer) WriteString(s string) (n int, err error) {
return
z
.
Buff
.
WriteString
(
s
)
}
func
(
z
*
Buffer
)
WriteAny
(
a
any
)
(
n
int
,
err
error
)
{
return
z
.
WriteString
(
fmt
.
Sprintf
(
"%v"
,
a
))
}
func
(
z
*
Buffer
)
Bytes
()
[]
byte
{
z
.
Mu
.
Lock
()
...
...
@@ -48,14 +52,12 @@ func (z *Buffer) Bytes() []byte {
return
z
.
Buff
.
Bytes
()
}
func
(
z
*
Buffer
)
String
()
string
{
z
.
Mu
.
Lock
()
defer
z
.
Mu
.
Unlock
()
return
z
.
Buff
.
String
()
}
func
(
z
*
Buffer
)
Reset
()
{
z
.
Mu
.
Lock
()
defer
z
.
Mu
.
Unlock
()
...
...
@@ -68,3 +70,10 @@ func (z *Buffer) Len() int {
return
z
.
Buff
.
Len
()
}
func
(
z
*
Buffer
)
Lock
()
{
z
.
Mu
.
Lock
()
}
func
(
z
*
Buffer
)
Unlock
()
{
z
.
Mu
.
Unlock
()
}
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