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
The hash maps behaves like hash maps, but are not backed by actual hashmaps, unlike with simpleredis. This is for keeping compatibility with simpleredis. If performance when scaling up is a concern, simpleredis backed by redis might be a better choice.
Sample usage
package main
import (
"log""github.com/terminar/simplesqlite"
)
funcmain() {
// Check if the simplesqlite is workingiferr:=db.TestConnection(); err!=nil {
log.Fatalln("Could not open database file.")
}
// Create a new Filefile:=db.New()
// Use another filename//file := db.NewFile("sqlite.db")// Close the connection when the function returnsdeferfile.Close()
// Create a list named "greetings"list, err:=db.NewList(file, "greetings")
iferr!=nil {
log.Fatalln("Could not create list!")
}
// Add "hello" to the list, check if there are errorsiflist.Add("hello") !=nil {
log.Fatalln("Could not add an item to list!")
}
// Get the last item of the listifitem, err:=list.GetLast(); err!=nil {
log.Fatalln("Could not fetch the last item from the list!")
} else {
log.Println("The value of the stored item is:", item)
}
// Remove the listiflist.Remove() !=nil {
log.Fatalln("Could not remove the list!")
}
}
Testing
The tests will create a file (sqlite.db) for go test to work.