Skip to content

Commit

Permalink
新增:Dictionary.New() 初始化(用于反映时使用)
Browse files Browse the repository at this point in the history
  • Loading branch information
steden committed Jan 13, 2024
1 parent f6f7221 commit a19718c
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions dictionary.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/json"
"errors"
"fmt"
"sync"
)

// Dictionary 字典
Expand Down Expand Up @@ -94,3 +95,12 @@ func (receiver *Dictionary[TKey, TValue]) ToReadonlyDictionary() ReadonlyDiction

return receiver.ReadonlyDictionary
}

// New 初始化(用于反映时使用)
func (receiver *Dictionary[TKey, TValue]) New() {
if receiver.source == nil {
var lock sync.RWMutex
receiver.source = make(map[TKey]TValue)
receiver.lock = &lock
}
}

0 comments on commit a19718c

Please sign in to comment.