Skip to content

pedromg/sstore

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

sstore

Simple Go key:value file storage

Open and store key:value specs, per line. Useful for in file definitions.

Use

To use it, just import the package in the import section:

import (
	"github.com/pedromg/sstore"
)

Then initialize a struct like:

var my_store sstore.SStore

To create a file:

my_store.Name = "filename" // can have path and extension. I use .sstore
my_store.Descr = "This is the first line, unusable but descriptive."
my_store.Data = map[string]string {
	"key1":"value1",
	"key2":"value2",
}
err := sstore.CreateFile(my_store)

That's it.

To read a file the struct is populated by the data, not the first line.

var err error
my_store, err = sstore.ReadFile("filename")
my_store.Data["key1"] // will return value1

Test

$ go test sstore_test.go

License

Copyright (c) pedro mg 2014 (pedro.mota@gmail.com) All code is licensed under the MIT License

About

Simple Go key:value file storage

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages