Last active
August 29, 2015 14:18
-
-
Save mpobrien/172b78a8d0a5a8904695 to your computer and use it in GitHub Desktop.
mgo unstable - test case
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"gopkg.in/mgo.v2" | |
) | |
func main() { | |
// connect to mongod | |
sess, err := mgo.Dial("localhost:33333") | |
if err != nil { | |
fmt.Println("error dialing mongod: ", err) | |
return | |
} | |
sess.SetSafe(nil) | |
gfs := sess.DB("mongofiles_test_db").GridFS("fs") | |
tf, err := gfs.Create("testfile2") | |
if err != nil { | |
fmt.Println("error creating file: ", err) | |
return | |
} | |
_, err = tf.Write([]byte("abcdefghijklmnopqrst")) | |
if err != nil { | |
fmt.Println("error writing file contents: ", err) | |
return | |
} | |
err = tf.Close() | |
if err != nil { | |
fmt.Println("error closing file: ", err) | |
} | |
err = gfs.Remove("testfile2") | |
if err != nil { | |
fmt.Println("error removing file: ", err) | |
return | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment