.. | ||
contentaddressable.go | ||
file_test.go | ||
file.go | ||
LICENSE | ||
README.md |
Content Addressable
Package contentaddressable contains tools for writing content addressable files. Files are written to a temporary location, and only renamed to the final location after the file's OID (Object ID) has been verified.
filename := "path/to/01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b"
file, err := contentaddressable.NewFile(filename)
if err != nil {
panic(err)
}
defer file.Close()
file.Oid // 01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b
written, err := io.Copy(file, someReader)
if err == nil {
// Move file to final location if OID is verified.
err = file.Accept()
}
if err != nil {
panic(err)
}
See the godocs for details.
Installation
$ go get github.com/technoweenie/go-contentaddressable
Then import it:
import "github.com/technoweenie/go-contentaddressable"
Note on Patches/Pull Requests
- Fork the project on GitHub.
- Make your feature addition or bug fix.
- Add tests for it. This is important so I don't break it in a future version unintentionally.
- Commit, do not mess with version or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
- Send me a pull request. Bonus points for topic branches.