Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
G
getty
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wei.xuan
getty
Commits
7e92b864
Commit
7e92b864
authored
Mar 31, 2019
by
AlexStocks
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
check session.attrs is nil or not when using it
parent
112d8b25
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
2 deletions
+10
-2
session.go
session.go
+10
-2
No files found.
session.go
View file @
7e92b864
...
...
@@ -280,6 +280,10 @@ func (s *session) SetWaitTime(waitTime time.Duration) {
// set attribute of key @session:key
func
(
s
*
session
)
GetAttribute
(
key
interface
{})
interface
{}
{
s
.
lock
.
RLock
()
if
s
.
attrs
==
nil
{
s
.
lock
.
Unlock
()
return
nil
}
ret
,
flag
:=
s
.
attrs
.
Get
(
key
)
s
.
lock
.
RUnlock
()
...
...
@@ -293,14 +297,18 @@ func (s *session) GetAttribute(key interface{}) interface{} {
// get attribute of key @session:key
func
(
s
*
session
)
SetAttribute
(
key
interface
{},
value
interface
{})
{
s
.
lock
.
Lock
()
s
.
attrs
.
Set
(
key
,
value
)
if
s
.
attrs
!=
nil
{
s
.
attrs
.
Set
(
key
,
value
)
}
s
.
lock
.
Unlock
()
}
// delete attribute of key @session:key
func
(
s
*
session
)
RemoveAttribute
(
key
interface
{})
{
s
.
lock
.
Lock
()
s
.
attrs
.
Delete
(
key
)
if
s
.
attrs
!=
nil
{
s
.
attrs
.
Delete
(
key
)
}
s
.
lock
.
Unlock
()
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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