Help us shape the future of Go! Take the 2026 Go Developer Survey

kevaf

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 13, 2018 License: MIT Imports: 3 Imported by: 1

README

kevaf

GoDoc codecov CircleCI

Lightweight file-base KVS for golang.

Install

go get github.com/inabajunmr/kevaf

Usage

package main

import (
	"fmt"
	"os"

	kevaf "github.com/inabajunmr/kevaf"
)

func main() {

	// prepare dir for kevaf
	os.Mkdir("./.kvs", 0777)
	kvs := kevaf.FileMap{"./.kvs"}

	// put new value
	err := kvs.Put("key", []byte("value"))
	if err != nil {
		fmt.Println("Failed to put.", err)
		os.Exit(1)
	}

	// get put value
	val, err := kvs.Get("key")
	if err != nil {
		fmt.Println("key is empty")
		os.Exit(1)
	}

	fmt.Println(string(val)) // value
}

Documentation

Overview

Package kevaf is light-weight filebase kvs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Map

type Map struct {
	Path string
}

Map is file base Kvs interface

func NewMap

func NewMap(path string) (*Map, error)

NewMap is Constructor

func (Map) Get

func (f Map) Get(key string) (value []byte, err error)

Get read file matching key underneath FileMap.Path

func (Map) Put

func (f Map) Put(key string, value []byte) error

Put create file by filename as key and content as value When failed to write file, return error

func (Map) Remove

func (f Map) Remove(key string) (err error)

Remove specific data by matching key

func (Map) RemoveAll

func (f Map) RemoveAll() (err error)

RemoveAll data

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL