diff options
Diffstat (limited to 'src/hub/src/spreadspace.org/sfive/s5cvt.go')
-rw-r--r-- | src/hub/src/spreadspace.org/sfive/s5cvt.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/hub/src/spreadspace.org/sfive/s5cvt.go b/src/hub/src/spreadspace.org/sfive/s5cvt.go index d828af7..24b458a 100644 --- a/src/hub/src/spreadspace.org/sfive/s5cvt.go +++ b/src/hub/src/spreadspace.org/sfive/s5cvt.go @@ -2,6 +2,7 @@ package sfive import ( "encoding/json" + "fmt" ) type StatsDecoder interface { @@ -26,6 +27,9 @@ func NewStatefulDecoder(jsonString []byte) (decoder StatsDecoder, err error) { if err != nil { return } + if res.sourceId.Version != 1 { + err = fmt.Errorf("unsupported version, expected 1, actual %v", res.sourceId.Version) + } decoder = res return } @@ -35,8 +39,8 @@ func NewPlainDecoder() (decoder StatsDecoder) { } func (self *StatefulDecoder) Decode(jsonString []byte) (dat StatisticsData, err error) { - err = json.Unmarshal(jsonString, &dat) dat.CopyFrom(&self.sourceId) + err = json.Unmarshal(jsonString, &dat) // like in PlainDecoder, let the client decide how to use partial results // (Unmarshal returns partial results in case of errors) return |