Skip to content

Commit

Permalink
hello_schema: replace TempFile with TempDir
Browse files Browse the repository at this point in the history
If TempFile is used cayley.NewGraph complains about
tmpfile.Name() not being a dir.
  • Loading branch information
mguentner committed Apr 17, 2018
1 parent ef2f25d commit c92d4f7
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions examples/hello_schema/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,17 @@ func main() {
}

// File for your new BoltDB. Use path to regular file and not temporary in the real world
tmpfile, err := ioutil.TempFile("", "example")
tmpdir, err := ioutil.TempDir("", "example")
checkErr(err)

defer os.Remove(tmpfile.Name()) // clean up
defer os.Remove(tmpdir) // clean up

// Initialize the database
graph.InitQuadStore("bolt", tmpfile.Name(), nil)
err = graph.InitQuadStore("bolt", tmpdir, nil)
checkErr(err)

// Open and use the database
store, err := cayley.NewGraph("bolt", tmpfile.Name(), nil)
store, err := cayley.NewGraph("bolt", tmpdir, nil)
checkErr(err)
defer store.Close()
qw := graph.NewWriter(store)
Expand Down

0 comments on commit c92d4f7

Please sign in to comment.