From 960d6a342ac848cabaee090656a2ae54d6cb1f13 Mon Sep 17 00:00:00 2001 From: Philip O'Toole Date: Sun, 28 Feb 2016 11:46:49 -0800 Subject: [PATCH 1/2] Alphabetical imports --- _example/hook/hook.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/_example/hook/hook.go b/_example/hook/hook.go index 3059f9e..c9f41a2 100644 --- a/_example/hook/hook.go +++ b/_example/hook/hook.go @@ -2,9 +2,10 @@ package main import ( "database/sql" - "github.com/mattn/go-sqlite3" "log" "os" + + "github.com/mattn/go-sqlite3" ) func main() { From baa815b31d0c13138a18524f23f4a2dab96d8273 Mon Sep 17 00:00:00 2001 From: Philip O'Toole Date: Sun, 28 Feb 2016 11:47:07 -0800 Subject: [PATCH 2/2] Fix reversed source and destination names --- _example/hook/hook.go | 48 +++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/_example/hook/hook.go b/_example/hook/hook.go index c9f41a2..17bddeb 100644 --- a/_example/hook/hook.go +++ b/_example/hook/hook.go @@ -20,36 +20,36 @@ func main() { os.Remove("./foo.db") os.Remove("./bar.db") - destDb, err := sql.Open("sqlite3_with_hook_example", "./foo.db") - if err != nil { - log.Fatal(err) - } - defer destDb.Close() - destDb.Ping() - - _, err = destDb.Exec("create table foo(id int, value text)") - if err != nil { - log.Fatal(err) - } - _, err = destDb.Exec("insert into foo values(1, 'foo')") - if err != nil { - log.Fatal(err) - } - _, err = destDb.Exec("insert into foo values(2, 'bar')") - if err != nil { - log.Fatal(err) - } - _, err = destDb.Query("select * from foo") - if err != nil { - log.Fatal(err) - } - srcDb, err := sql.Open("sqlite3_with_hook_example", "./bar.db") + srcDb, err := sql.Open("sqlite3_with_hook_example", "./foo.db") if err != nil { log.Fatal(err) } defer srcDb.Close() srcDb.Ping() + _, err = srcDb.Exec("create table foo(id int, value text)") + if err != nil { + log.Fatal(err) + } + _, err = srcDb.Exec("insert into foo values(1, 'foo')") + if err != nil { + log.Fatal(err) + } + _, err = srcDb.Exec("insert into foo values(2, 'bar')") + if err != nil { + log.Fatal(err) + } + _, err = srcDb.Query("select * from foo") + if err != nil { + log.Fatal(err) + } + destDb, err := sql.Open("sqlite3_with_hook_example", "./bar.db") + if err != nil { + log.Fatal(err) + } + defer destDb.Close() + destDb.Ping() + bk, err := sqlite3conn[1].Backup("main", sqlite3conn[0], "main") if err != nil { log.Fatal(err)