所有操作加锁

This commit is contained in:
zhangdeman committed 2025-05-06 16:02:14 +08:00
1 parent 691bee91a5
commit 777a5cb93c
1 file changed
+6 -2
+6 -2
View File
@@ -32,6 +32,8 @@ func (s *SjsonWrite) Delete(dataPath string) error {
var (
err error
)
s.l.Lock()
defer s.l.Unlock()
if s.res, err = sjson.Delete(s.res, dataPath); nil != err {
return err
}
@@ -90,6 +92,8 @@ func (s *SjsonWrite) Set(dataPath string, data any) error {
}
func (s *SjsonWrite) Result() string {
s.l.RLock()
defer s.l.RUnlock()
return s.res
}
@@ -105,7 +109,7 @@ func (s *SjsonWrite) Map() (map[string]any, error) {
}
func (s *SjsonWrite) MapWithReceiver(receiver any) error {
return serialize.JSON.UnmarshalWithNumberForString(s.res, receiver)
return serialize.JSON.UnmarshalWithNumberForString(s.Result(), receiver)
}
func (s *SjsonWrite) Array() ([]any, error) {
@@ -120,5 +124,5 @@ func (s *SjsonWrite) Array() ([]any, error) {
}
func (s *SjsonWrite) ArrayWithReceiver(receiver any) error {
return serialize.JSON.UnmarshalWithNumberForString(s.res, receiver)
return serialize.JSON.UnmarshalWithNumberForString(s.Result(), receiver)
}
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.