You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Simple way to use the Bolt database. Similar design to simpleredis.
Features and limitations
Supports simple use of lists, hashmaps, sets and key/values.
Deals mainly with strings.
Requires Go 1.17 or later.
Note that HashMap is implemented only for API-compatibility with simpleredis, and does not have the same performance profile as the HashMap implementation in simpleredis, simplemaria (MariaDB/MySQL) or simplehstore (PostgreSQL w/ HSTORE).
Example usage
package main
import (
"log""github.com/xyproto/simplebolt"
)
funcmain() {
// New bolt database structdb, err:=simplebolt.New("bolt.db")
iferr!=nil {
log.Fatalf("Could not create database! %s", err)
}
deferdb.Close()
// Create a list named "greetings"list, err:=simplebolt.NewList(db, "greetings")
iferr!=nil {
log.Fatalf("Could not create a list! %s", err)
}
// Add "hello" to the listiferr:=list.Add("hello"); err!=nil {
log.Fatalf("Could not add an item to the list! %s", err)
}
// Get the last item of the listifitem, err:=list.Last(); err!=nil {
log.Fatalf("Could not fetch the last item from the list! %s", err)
} else {
log.Println("The value of the stored item is:", item)
}
// Remove the listiferr:=list.Remove(); err!=nil {
log.Fatalf("Could not remove the list! %s", err)
}
}