Can someone explain me the difference between the default value of SetSafe()
which
is &Safe{}and SetSafe(nil)?
As per the mgo godoc <https://godoc.org/gopkg.in/mgo.v2#Session.SetSafe>:-
If the safe parameter is nil, the session is put in unsafe mode, and writes
become fire-and-forget, without error checking. The unsafe mode is faster since
operations won't hold on waiting for a confirmation.
If the safe parameter is not nil, any changing query (insert, update, ...) will
be followed by a getLastError command with the specified parameters, to ensure
the request was correctly processed.
The default is &Safe{}, meaning check for errors and use the default behavior
for all fields.
Looking at the code
<http://bazaar.launchpad.net/+branch/mgo/v2/view/head:/session.go#L1540> it
seems it will call getLastError with values j:false, w:0, wtimeout:0. This
means it will not return any error from mongo and the behavior seems to be
similar while calling SetSafe(nil).
Then what error I am expected to receive while calling mongo with
SetSafe(&Safe{})?
I am on Mongo 3.0.9.
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.