codenotary / immudb

immudb - immutable database based on zero trust, SQL/Key-Value/Document model, tamperproof, data change history
https://immudb.io
Other
8.55k stars 343 forks source link

fix: time.Since should not be used in defer statement #2014

Closed druzn3k closed 3 weeks ago

druzn3k commented 3 weeks ago

This commit fixes the complaining from go vet about the deferring of time.Since. This can cause wrong time evaluation of the elapsed time. This impact only the debug level, but still it should be addressed.

ref: https://github.com/golang/go/issues/60048

Signed-off-by: Maurizio Del Corno druznek@gmail.com

coveralls commented 3 weeks ago

Coverage Status

coverage: 89.491% (-0.004%) from 89.495% when pulling 8a247409e224e639d0835d9cb802265ff707ffb0 on druzn3k:fix/make-vet-happy-with-time-since-deferring into c0b6e0122acc86948819e596182728b12cdea625 on codenotary:master.

ostafen commented 3 weeks ago

@druzn3k: maybe adding a debug method to immuClient to wrap the call could simplify the code

druzn3k commented 3 weeks ago

@druzn3k: maybe adding a debug method to immuClient to wrap the call could simplify the code

Why not :) I'm thinking about something in this ballpark:

func (c *immuClient) debugWithTimeElapsed(msg string, start time.Time)

The name is on the ugly side though, but I can't come up with something better on the spot. Suggestions?

ostafen commented 3 weeks ago

maybe:

func (c *immuClient) debugElapsedTime(method string, start *time.Time)

You could just pass the method name

druzn3k commented 3 weeks ago

done @ostafen . Let me know if you like this version better.

ostafen commented 3 weeks ago

@druzn3k: looks good to me, thanks!