-
Type:
Task
-
Resolution: Works as Designed
-
Priority:
Major - P3
-
None
-
Affects Version/s: 1.0.1
-
Component/s: CRUD
-
None
-
Environment:set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\apple\AppData\Local\go-build
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\gowork\
set GOPROXY=
set GORACE=
set GOROOT=C:\Go
set GOTMPDIR=
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\apple\AppData\Local\Temp\go-build881616438=/tmp/go-build -gno-record-gcc-switchesset GOARCH=amd64 set GOBIN= set GOCACHE=C:\Users\apple\AppData\Local\go-build set GOEXE=.exe set GOFLAGS= set GOHOSTARCH=amd64 set GOHOSTOS=windows set GOOS=windows set GOPATH=C:\gowork\ set GOPROXY= set GORACE= set GOROOT=C:\Go set GOTMPDIR= set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64 set GCCGO=gccgo set CC=gcc set CXX=g++ set CGO_ENABLED=1 set GOMOD= set CGO_CFLAGS=-g -O2 set CGO_CPPFLAGS= set CGO_CXXFLAGS=-g -O2 set CGO_FFLAGS=-g -O2 set CGO_LDFLAGS=-g -O2 set PKG_CONFIG=pkg-config set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\apple\AppData\Local\Temp\go-build881616438=/tmp/go-build -gno-record-gcc-switches
-
None
-
None
-
None
-
None
-
None
-
None
-
None
After I create an unique index for a field of a document, I insert a duplicate document into mongodb, when using mgo it reports duperr, but user this driver, it reports "client is disconnected" and it disconnects from server either.
IMO, this error should not close the connection to the mongodb server, but just report/return an proper error.
mongo.InitMongo() client := mongo.GetClient() c := client.Database("api-server").Collection("users") var user = bson.M{"name":"bob","age":12} //duplicate document r, err := c.InsertOne(nil, user) if err != nil { println(err.Error()) //reports client is disconnected } // test if really disconnected var result bson.M err=c.FindOne(nil, bson.M{"name":"bob"}).Decode(&result) if err != nil { glog.Errorln(err) // really disconnected return } println(result["age"])