Can someone help me in clearing my doubts? On Aug 4, 2016 4:36 PM, "DM" <subharaj.ma...@gmail.com> wrote:
> 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 a topic in the > Google Groups "golang-nuts" group. > To unsubscribe from this topic, visit https://groups.google.com/d/ > topic/golang-nuts/Mdc4ntGIvwE/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > golang-nuts+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- 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 golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.