#log
log.Log is an array on disk. It can be appended or truncated (all action is at the end). It keeps track of the last index to which data is written (-1 if the log is empty)
import "github.com/cs733-iitb/log"
lg, _ := log.Open("mylog")
defer lg.Close()
lg.Append([]byte("foo"))
lg.Append([]byte("bar"))
lg.Append([]byte("baz"))
bytes, _ := lg.Get(1) // should return "bar" in bytes
i := lg.GetLastIndex() // should return 2 as an int64 value
lg.TruncateToEnd(/*from*/ 1)
i = lg.GetLastIndex() // should return 0. One entry is left.
go get github.com/cs733-iit/log
go test -race github.com/cs733-iitb/log
This library depends on the github.com/syndtr/leveldb
This library is a quick and dirty and inefficient solution. Treat it like a toy.
##Author: Sriram Srinivasan. sriram at malhar.net