Announcing mgo r2011.04.24, with GridFS support

Skip to first unread message

Gustavo Niemeyer

Apr 25, 2011, 12:29:10 AM4/25/11
to golang-nuts,,
The r2011.04.24 "easter" release of the mgo MongoDB driver
for Go is out, and brings a nice egg with it.

Here is a list of changes in this release:

- GridFS support! Now mgo can be used to send and receive
files to MongoDB using the standard GridFS specification
for file storage. This means that it may share the same
database collections used for file storage with drivers
for other languages, and also the command line tools
provided with MongoDB itself (e.g. mongofiles).

In addition to a selection of relevant methods, the
*mgo.GridFSFile type implements support for both io.Reader
and io.Writer interfaces, which means it integrates
nicely with the standard library.

Here is a simple example storing a file of arbitrary size
into the database:

file, err := db.GridFS("fs").Create("myfile.txt")
iso, err := os.Open("cd.iso")
defer iso.Close()
err = ioutil.Copy(file, iso)
err = file.Close()

Some entry points to relevant documentation:

- gobson got improved handling of pointers to basic types
so that it's easier to manage types which are unset.

- Fixed conditional support ("/c") for pointers in gobson.

Gustavo Niemeyer

Gustavo Niemeyer

Apr 25, 2011, 9:17:30 AM4/25/11
to Steven, golang-nuts,,
Hi Steven,

> I'm assuming, though, that check(err) is just a stand-in for actual
> error handling.

Yes, do the proper error checking for your own use please. The
intention was to drive attention to the actual logic rather than the
error checking, but apparently it didn't work.

Reply all
Reply to author
0 new messages