Documentation
¶
Overview ¶
Example ¶
Output: "2.0.0"{"first_name":"John","last_name":"Smith"}
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrNotVersioned error is raised if the underlying reader has no version ErrNotVersioned = fmt.Errorf("no version information") )
Functions ¶
func IsNotVersioned ¶
IsNotVersioned checks if error is caused by a 'not versioned' stream
Types ¶
type Reader ¶
Reader is a versioned reader The Versioned Reader is a reader that can load the version of the data from a stream without assuming anything regarding the underlying encoding of your data object
func NewReader ¶
NewReader creates a new versioned reader from a stream. It fails if the reader can not read the version from the stream. On success, the reader will have a version, and then can be used to load the data.
Example ¶
Output: data version is: 1.0.1 data is: my data goes here
func NewVersionedReader ¶
NewVersionedReader creates a versioned reader from an un-versioned reader. It's usually used to unify the data migration work flow in case the older data file didn't have a version stamp example:
reader, err := NewReader(file) if IsNotVersioned(err) { file.Seek(0, 0) // this is important to make u reading from start reader = NewVersionedReader(MustParse("0.0.0"), file) } else err != nil { // probably io error }
Click to show internal directories.
Click to hide internal directories.