easykoo / simplebolt

:nut_and_bolt: Simple way to use the Bolt database

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Simple Bolt Build Status GoDoc

Simple way to use the Bolt database. Similar design to simpleredis.

Online API Documentation

godoc.org

Features and limitations

  • Supports simple use of lists, hashmaps, sets and key/values.
  • Deals mainly with strings.
  • Requires Go 1.3 or later.
  • The latest version of gccgo (7.2.0) is able to compile simplebolt, but it does not appear to be able to compile it correctly. There are runtime errors when running go test, that work fine when compiling simplebolt with the regular Go compiler.

Example usage

package main

import (
	"log"

	"github.com/xyproto/simplebolt"
)

func main() {
	// New bolt database
	db, err := simplebolt.New("bolt.db")
	if err != nil {
		log.Fatalf("Could not create database! %s", err)
	}
	defer db.Close()

	// Create a list named "greetings"
	list, err := simplebolt.NewList(db, "greetings")
	if err != nil {
		log.Fatalf("Could not create a list! %s", err)
	}

	// Add "hello" to the list
	if err := list.Add("hello"); err != nil {
		log.Fatalf("Could not add an item to the list! %s", err)
	}

	// Get the last item of the list
	if item, err := list.GetLast(); 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 list
	if err := list.Remove(); err != nil {
		log.Fatalf("Could not remove the list! %s", err)
	}
}

Version, license and author

About

:nut_and_bolt: Simple way to use the Bolt database

License:MIT License


Languages

Language:Go 100.0%