Documentation
¶
Index ¶
Constants ¶
View Source
const (
// HashSize is the length of a Hash in bytes.
HashSize = 32
)
Variables ¶
View Source
var ( // ErrBadFilenameSuffix indicates that SaveJSON or LoadJSON was called using // a filename that has a bad suffix. This prevents users from trying to use // this package to manage the temp files - this package will manage them // automatically. ErrBadFilenameSuffix = errors.New("filename suffix not allowed") // ErrFileInUse is returned if SaveJSON or LoadJSON is called on a file // that's already being manipulated in another thread by the persist // package. ErrFileInUse = errors.New("another thread is saving or loading this file") )
View Source
var ( // ErrBadHeader indicates that the file opened is not the file that was // expected. ErrBadHeader = errors.New("wrong header") // ErrBadVersion indicates that the version number of the file is not // compatible with the current codebase. ErrBadVersion = errors.New("incompatible version") )
View Source
var ( // ErrHashWrongLen is the error when encoded value has the wrong // length to be a hash. ErrHashWrongLen = errors.New("encoded value has the wrong length to be a hash") )
Functions ¶
func SaveJSON ¶
SaveJSON will save a json object to disk in a durable, atomic way. The resulting file will have a checksum of the data as the third line. If manually editing files, the checksum line can be replaced with the 8 characters "manual". This will cause the reader to accept the checksum even though the file has been changed.
Types ¶
type Hash ¶
Hash is a BLAKE2b 256-bit digest.
func (Hash) MarshalJSON ¶
MarshalJSON marshales a hash as a hex string.
func (*Hash) UnmarshalJSON ¶
UnmarshalJSON decodes the json hex string of the hash.
Click to show internal directories.
Click to hide internal directories.