Skip to content

Commit 2cd5a0a

Browse files
committed
Data now returns a copy of the data
1 parent f662658 commit 2cd5a0a

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

Session.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,13 @@ func (session *Session) Modified() bool {
6767
return session.modified
6868
}
6969

70-
// Data returns the underlying session data.
71-
// READING OR WRITING DATA IS NOT THREAD-SAFE.
72-
// Use Set() and Get() to modify data safely.
70+
// Data returns a copy of the underlying session data.
7371
func (session *Session) Data() map[string]interface{} {
74-
return session.data
72+
newMap := map[string]interface{}{}
73+
74+
for key, value := range session.data {
75+
newMap[key] = value
76+
}
77+
78+
return newMap
7579
}

0 commit comments

Comments
 (0)