Add 'Set' for interface{} type
This commit is contained in:
parent
a3bfc9ba7b
commit
4c7d152811
15
boltease.go
15
boltease.go
@ -2,6 +2,7 @@ package boltease
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"strconv"
|
||||
@ -100,6 +101,20 @@ func (b *DB) MkBucketPath(path []string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (b *DB) Set(path []string, key string, val interface{}) error {
|
||||
switch v := val.(type) {
|
||||
case string:
|
||||
return b.SetValue(path, key, v)
|
||||
case int:
|
||||
return b.SetInt(path, key, v)
|
||||
case bool:
|
||||
return b.SetBool(path, key, v)
|
||||
case []byte:
|
||||
return b.SetBytes(path, key, v)
|
||||
}
|
||||
return errors.New("Unknown Data Type")
|
||||
}
|
||||
|
||||
func (b *DB) GetBytes(path []string, key string) ([]byte, error) {
|
||||
var err error
|
||||
var ret []byte
|
||||
|
Loading…
Reference in New Issue
Block a user