fix: use pointer methods

This commit is contained in:
Derrick Hammer 2024-03-09 07:11:53 -05:00
parent 3bd336b000
commit 0e82207cde
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 6 additions and 6 deletions

View File

@ -15,7 +15,7 @@ type BboltDBKVStore struct {
dbPath string dbPath string
} }
func (b BboltDBKVStore) Open() error { func (b *BboltDBKVStore) Open() error {
if b.root && b.db == nil { if b.root && b.db == nil {
db, err := bbolt.Open(b.dbPath, 0666, nil) db, err := bbolt.Open(b.dbPath, 0666, nil)
if err != nil { if err != nil {
@ -41,7 +41,7 @@ func (b BboltDBKVStore) Open() error {
return nil return nil
} }
func (b BboltDBKVStore) Close() error { func (b *BboltDBKVStore) Close() error {
if b.root && b.db != nil { if b.root && b.db != nil {
err := b.db.Close() err := b.db.Close()
if err != nil { if err != nil {
@ -52,7 +52,7 @@ func (b BboltDBKVStore) Close() error {
return nil return nil
} }
func (b BboltDBKVStore) Get(key []byte) ([]byte, error) { func (b *BboltDBKVStore) Get(key []byte) ([]byte, error) {
if b.root { if b.root {
return nil, errors.New("Cannot get from root") return nil, errors.New("Cannot get from root")
} }
@ -70,7 +70,7 @@ func (b BboltDBKVStore) Get(key []byte) ([]byte, error) {
return val, nil return val, nil
} }
func (b BboltDBKVStore) Put(key []byte, value []byte) error { func (b *BboltDBKVStore) Put(key []byte, value []byte) error {
if b.root { if b.root {
return errors.New("Cannot put from root") return errors.New("Cannot put from root")
@ -88,7 +88,7 @@ func (b BboltDBKVStore) Put(key []byte, value []byte) error {
return err return err
} }
func (b BboltDBKVStore) Delete(key []byte) error { func (b *BboltDBKVStore) Delete(key []byte) error {
if b.root { if b.root {
return errors.New("Cannot delete from root") return errors.New("Cannot delete from root")
} }
@ -105,7 +105,7 @@ func (b BboltDBKVStore) Delete(key []byte) error {
return err return err
} }
func (b BboltDBKVStore) Bucket(prefix string) (KVStore, error) { func (b *BboltDBKVStore) Bucket(prefix string) (KVStore, error) {
return &BboltDBKVStore{ return &BboltDBKVStore{
db: b.db, db: b.db,
bucketName: prefix, bucketName: prefix,