| 1 |
From 0c8e943f2b19e9c8750e7f789b318cd2ee382463 Mon Sep 17 00:00:00 2001 |
| 2 |
From: Andreas Henriksson <[email protected]> |
| 3 |
Date: Wed, 13 Apr 2022 17:59:43 +0200 |
| 4 |
Subject: [PATCH] Drop unused variables in lmdb/example_test.go |
| 5 |
|
| 6 |
This fixes build with go 1.18. |
| 7 |
|
| 8 |
Fixes: #143 |
| 9 |
--- |
| 10 |
lmdb/example_test.go | 24 ++++++++---------------- |
| 11 |
1 file changed, 8 insertions(+), 16 deletions(-) |
| 12 |
|
| 13 |
diff --git a/lmdb/example_test.go b/lmdb/example_test.go |
| 14 |
index 63a5022..0935d4d 100644 |
| 15 |
--- a/lmdb/example_test.go |
| 16 |
+++ b/lmdb/example_test.go |
| 17 |
@@ -338,12 +338,11 @@ func ExampleEnv() { |
| 18 |
} |
| 19 |
defer env.Close() |
| 20 |
|
| 21 |
- var dbi lmdb.DBI |
| 22 |
err = env.Update(func(txn *lmdb.Txn) (err error) { |
| 23 |
// open a database, creating it if necessary. the database is stored |
| 24 |
// outside the transaction via closure and can be use after the |
| 25 |
// transaction is committed. |
| 26 |
- dbi, err = txn.OpenDBI("exampledb", lmdb.Create) |
| 27 |
+ _, err = txn.OpenDBI("exampledb", lmdb.Create) |
| 28 |
if err != nil { |
| 29 |
return err |
| 30 |
} |
| 31 |
@@ -665,9 +664,8 @@ func ExampleCursor_Del() { |
| 32 |
func ExampleTxn_OpenDBI() { |
| 33 |
// DBI handles can be saved after their opening transaction has committed |
| 34 |
// and may be reused as long as the environment remains open. |
| 35 |
- var dbi lmdb.DBI |
| 36 |
err = env.Update(func(txn *lmdb.Txn) (err error) { |
| 37 |
- dbi, err = txn.OpenDBI("dbfound", 0) |
| 38 |
+ _, err = txn.OpenDBI("dbfound", 0) |
| 39 |
return err |
| 40 |
}) |
| 41 |
if err != nil { |
| 42 |
@@ -679,9 +677,8 @@ func ExampleTxn_OpenDBI() { |
| 43 |
// didn't already exist. An error will be returned if the name is occupied by |
| 44 |
// data written by Txn./Cursor.Put(). |
| 45 |
func ExampleTxn_OpenDBI_create() { |
| 46 |
- var dbi lmdb.DBI |
| 47 |
err = env.Update(func(txn *lmdb.Txn) (err error) { |
| 48 |
- dbi, err = txn.OpenDBI("dbnew", lmdb.Create) |
| 49 |
+ _, err = txn.OpenDBI("dbnew", lmdb.Create) |
| 50 |
return err |
| 51 |
}) |
| 52 |
if err != nil { |
| 53 |
@@ -693,9 +690,8 @@ func ExampleTxn_OpenDBI_create() { |
| 54 |
// NotFound. If an application needs to handle this case the function |
| 55 |
// IsNotFound() will test an error for this condition. |
| 56 |
func ExampleTxn_OpenDBI_notFound() { |
| 57 |
- var dbi lmdb.DBI |
| 58 |
err = env.Update(func(txn *lmdb.Txn) (err error) { |
| 59 |
- dbi, err = txn.OpenDBI("dbnotfound", 0) |
| 60 |
+ _, err = txn.OpenDBI("dbnotfound", 0) |
| 61 |
return err |
| 62 |
}) |
| 63 |
log.Print(err) // mdb_dbi_open: MDB_NOTFOUND: No matching key/data pair found |
| 64 |
@@ -706,9 +702,8 @@ func ExampleTxn_OpenDBI_notFound() { |
| 65 |
// return an error with errno DBsFull. If an application needs to handle this |
| 66 |
// case then the function IsError() can test an error for this condition. |
| 67 |
func ExampleTxn_OpenDBI_dBsFull() { |
| 68 |
- var dbi lmdb.DBI |
| 69 |
err = env.Update(func(txn *lmdb.Txn) (err error) { |
| 70 |
- dbi, err = txn.OpenDBI("dbnotexist", 0) |
| 71 |
+ _, err = txn.OpenDBI("dbnotexist", 0) |
| 72 |
return err |
| 73 |
}) |
| 74 |
log.Print(err) // mdb_dbi_open: MDB_DBS_FULL: Environment maxdbs limit reached |
| 75 |
@@ -717,9 +712,8 @@ func ExampleTxn_OpenDBI_dBsFull() { |
| 76 |
// Txn.OpenRoot does not need to be called with the Create flag. And |
| 77 |
// Txn.OpenRoot, unlike Txn.OpenDBI, will never produce the error DBsFull. |
| 78 |
func ExampleTxn_OpenRoot() { |
| 79 |
- var dbi lmdb.DBI |
| 80 |
err = env.Update(func(txn *lmdb.Txn) (err error) { |
| 81 |
- dbi, err = txn.OpenRoot(0) |
| 82 |
+ _, err = txn.OpenRoot(0) |
| 83 |
return err |
| 84 |
}) |
| 85 |
if err != nil { |
| 86 |
@@ -766,8 +760,7 @@ func ExampleTxn_OpenRoot_view() { |
| 87 |
func ExampleTxn_Get() { |
| 88 |
// variables to hold data extracted from the database |
| 89 |
var point struct{ X, Y int } |
| 90 |
- var str string |
| 91 |
- var p1, p2 []byte |
| 92 |
+ var p1 []byte |
| 93 |
|
| 94 |
// extract data from an example environment/database. it is critical for application |
| 95 |
// code to handle errors but that is omitted here to save space. |
| 96 |
@@ -775,7 +768,6 @@ func ExampleTxn_Get() { |
| 97 |
// OK |
| 98 |
// A []byte to string conversion will always copy the data |
| 99 |
v, _ := txn.Get(DBIEx, []byte("mykey")) |
| 100 |
- str = string(v) |
| 101 |
|
| 102 |
// OK |
| 103 |
// If []byte is the desired data type then an explicit copy is required |
| 104 |
@@ -794,7 +786,7 @@ func ExampleTxn_Get() { |
| 105 |
// Assigning the result directly to p2 leaves its pointer volatile |
| 106 |
// after the transaction completes which can result in unpredictable |
| 107 |
// behavior. |
| 108 |
- p2, _ = txn.Get(DBIEx, []byte("mykey")) |
| 109 |
+ _, _ = txn.Get(DBIEx, []byte("mykey")) |
| 110 |
|
| 111 |
return nil |
| 112 |
}) |
| 113 |
-- |
| 114 |
2.30.2 |
| 115 |
|