Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
module github.com/goombaio/orderedmap
module github.com/shiyuleixia/orderedmap

go 1.15
6 changes: 3 additions & 3 deletions orderedmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
// OrderedMap represents an associative array or map abstract data type.
type OrderedMap struct {
// mu Mutex protects data structures below.
mu sync.Mutex
mu sync.RWMutex

// keys is the Set list of keys.
keys []interface{}
Expand Down Expand Up @@ -60,8 +60,8 @@ func (m *OrderedMap) Put(key interface{}, value interface{}) {

// Get returns the value of a key from the OrderedMap.
func (m *OrderedMap) Get(key interface{}) (value interface{}, found bool) {
m.mu.Lock()
defer m.mu.Unlock()
m.mu.RLock()
defer m.mu.RUnlock()

value, found = m.store[key]
return value, found
Expand Down