-
Notifications
You must be signed in to change notification settings - Fork 27
Closed
Description
Line 150 in 42e9432
| s.p.RUnlock() |
The Go Language Reference document Section "Assignment statements" says:
"When a value is assigned to a variable, only the data that is stored in the variable is replaced. If the value contains a reference, the assignment copies the reference but does not make a copy of the referenced data (such as the underlying array of a slice)."
Would moving s.p.RUnlock() to after the loop be safer?
// GetTasks() returns a list of all tasks registered with the server.
func (s *Server) GetTasks() []string {
s.p.RLock()
tasks := s.tasks
var (
t = make([]string, len(tasks))
i = 0
)
for k := range tasks {
t[i] = k
i++
}
s.p.RUnlock()
return t
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels