V
V
Vladimir Grabko2016-08-01 02:14:16
go
Vladimir Grabko, 2016-08-01 02:14:16

How to shorten an entry?

I wanted something like this:

rw.Lock()
  m_sessionStorage[sessid].Up = time.Now().Unix()
 rw.Unlock()

For obvious reasons, it didn't work. After rereading the Go specification, I came up with the following:
rw.Lock()
  gg := m_sessionStorage[sessid]
  gg.Up = time.Now().Unix()
  m_sessionStorage[sessid] = gg
  rw.Unlock()

How can this be shortened?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
index0h, 2016-08-01
@VGrabko

Use pointers in the map

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question