File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change 33package fluent
44
55import (
6+ "fmt"
67 "time"
78
89 "github.com/tinylib/msgp/msgp"
@@ -93,8 +94,19 @@ func (t *EventTime) MarshalBinaryTo(b []byte) error {
9394 return nil
9495}
9596
96- // UnmarshalBinary is not implemented since decoding messages is not supported
97- // by this library .
97+ // Although decoding messages is not officially supported by this library,
98+ // UnmarshalBinary is implemented for testing and general completeness .
9899func (t * EventTime ) UnmarshalBinary (b []byte ) error {
100+ if len (b ) != length {
101+ return fmt .Errorf ("Invalid EventTime byte length: %d" , len (b ))
102+ }
103+
104+ sec := (int32 (b [0 ]) << 24 ) | (int32 (b [1 ]) << 16 )
105+ sec = sec | (int32 (b [2 ]) << 8 ) | int32 (b [3 ])
106+
107+ nsec := (int32 (b [4 ]) << 24 ) | (int32 (b [5 ]) << 16 )
108+ nsec = nsec | (int32 (b [6 ]) << 8 ) | int32 (b [7 ])
109+
110+ * t = EventTime (time .Unix (int64 (sec ), int64 (nsec )))
99111 return nil
100112}
You can’t perform that action at this time.
0 commit comments