func (gfs *GridFS) Open(name string) (file *GridFile, err error) {
	var doc gfsFile
	err = gfs.Files.Find(bson.M{"filename": name}).Sort("-uploadDate").One(&doc)
	if err != nil {
		return
	}
	file = gfs.newFile()
	file.mode = gfsReading
	file.doc = doc
	return
}
func (gfs *GridFS) Open(name string) (file *GridFile, err error) {
	var doc gfsFile
	err = gfs.Files.Find(bson.M{"filename": name}).Sort("-uploadDate").One(&doc)
	if err != nil {
		return
	}
	file = gfs.newFile()
	file.mode = gfsReading
	file.doc = doc
	return
}
func ( gfs * GridFS ) Open ( name string ) ( file * GridFile , err error ) { var doc gfsFile err = gfs . Files . Find ( bson . M { " " : name } ) . Sort ( " " ) . One ( & doc ) if err != nil { return } file = gfs . newFile ( ) file . mode = gfsReading file . doc = doc return }
// Open returns the most recently uploaded file with the provided
// name, for reading. If the file isn't found, err will be set
// to mgo.ErrNotFound.
//
// It's important to Close files whether they are being written to
// or read from, and to check the err result to ensure the operation
// completed successfully.
//
// The following example will print the first 8192 bytes from the file:
//
//     file, err := db.GridFS("fs").Open("myfile.txt")
//     check(err)
//     b := make([]byte, 8192)
//     n, err := file.Read(b)
//     check(err)
//     fmt.Println(string(b))
//     check(err)
//     err = file.Close()
//     check(err)
//     fmt.Printf("%d bytes read\n", n)
//
// The io.Reader interface is implemented by *GridFile and may be used to
// deal with it.  As an example, the following snippet will dump the whole
// file into the standard output:
//
//     file, err := db.GridFS("fs").Open("myfile.txt")
//     check(err)
//     err = io.Copy(os.Stdout, file)
//     check(err)
//     err = file.Close()
//     check(err)
//
Open returns the most recently uploaded file with the provided name for reading . If the file isn t found err will be set to mgo . ErrNotFound . It s important to Close files whether they are being written to or read from and to check the err result to ensure the operation completed successfully . The following example will print the first 8192 bytes from the file : file err : = db . GridFS ( fs ) . Open ( myfile . txt ) check ( err ) b : = make ( [] byte 8192 ) n err : = file . Read ( b ) check ( err ) fmt . Println ( string ( b )) check ( err ) err = file . Close () check ( err ) fmt . Printf ( %d bytes read \ n n ) The io . Reader interface is implemented by * GridFile and may be used to deal with it . As an example the following snippet will dump the whole file into the standard output : file err : = db . GridFS ( fs ) . Open ( myfile . txt ) check ( err ) err = io . Copy ( os . Stdout file ) check ( err ) err = file . Close () check ( err )