Simple Go key:value file storage
Open and store key:value specs, per line. Useful for in file definitions.
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
$ go test sstore_test.go
Copyright (c) pedro mg 2014 (pedro.mota@gmail.com) All code is licensed under the MIT License