-
-
Notifications
You must be signed in to change notification settings - Fork 200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Zachmu/logger #536
Zachmu/logger #536
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Beautiful
s.mu.Lock() | ||
sess, ok := s.sessions[conn.ConnectionID] | ||
ir := s.idxRegs[conn.ConnectionID] | ||
vr := s.viewRegs[conn.ConnectionID] | ||
if !ok { | ||
var err error | ||
sess, ir, vr, err = s.builder(ctx, conn, s.addr) | ||
s.mu.Unlock() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not an actionable comment, but just something I wish Go had. In C# they have the lock
command where some block of code executes under a mutex, guaranteeing that the mutex is always released once leaving the block's scope. In Go we have to declare a function and use defer
to get something equivalent, while adding some pains with return handling and whatnot. Just wishing...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah go locking is lame, I blame Rob Pike
No description provided.