Skip to content

Instantly share code, notes, and snippets.

@eamonnmcevoy
Last active March 12, 2017 12:15
Show Gist options
  • Save eamonnmcevoy/ccff3328ed50b6d2ce9a36e2037135a3 to your computer and use it in GitHub Desktop.
Save eamonnmcevoy/ccff3328ed50b6d2ce9a36e2037135a3 to your computer and use it in GitHub Desktop.
package mongo
import (
"gopkg.in/mgo.v2"
)
type Session struct {
session *mgo.Session
}
func(s *Session) Open() error {
var err error
s.session, err = mgo.Dial("127.0.0.1:27017")
if err != nil {
return err
}
s.session.SetMode(mgo.Monotonic, true)
return nil
}
func(s *Session) Copy() *mgo.Session {
return s.session.Copy()
}
func(s *Session) Close() {
if(s.session != nil) {
s.session.Close()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment