Announcing mgo r2011.04.24, with GridFS support

52 views
Skip to first unread message

Gustavo Niemeyer

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

http://labix.org/mgo

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")
check(err)
iso, err := os.Open("cd.iso")
check(err)
defer iso.Close()
err = ioutil.Copy(file, iso)
check(err)
err = file.Close()
check(err)

Some entry points to relevant documentation:

http://goneat.org/lp/mgo#Database.GridFS
http://goneat.org/lp/mgo#GridFS.Create
http://goneat.org/lp/mgo#GridFS.Open
http://goneat.org/lp/mgo#GridFS.OpenId

- 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
http://niemeyer.net
http://niemeyer.net/blog
http://niemeyer.net/twitter

Gustavo Niemeyer

unread,
Apr 25, 2011, 9:17:30 AM4/25/11
to Steven, golang-nuts, mongod...@googlegroups.com, mgo-...@googlegroups.com
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
Forward
0 new messages