Skip to content

Commit

Permalink
Update write.go
Browse files Browse the repository at this point in the history
Change the time comparison to use Equal, which is safer with timestamps in go.

Use IsZero()
  • Loading branch information
pinkfish authored and lukebakken committed Sep 24, 2023
1 parent 97a7db0 commit 4a77835
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions write.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ func (f *heartbeatFrame) write(w io.Writer) (err error) {
// short short long long short remainder...
func (f *headerFrame) write(w io.Writer) (err error) {
var payload bytes.Buffer
var zeroTime time.Time

if err = binary.Write(&payload, binary.BigEndian, f.ClassId); err != nil {
return
Expand Down Expand Up @@ -118,7 +117,7 @@ func (f *headerFrame) write(w io.Writer) (err error) {
if len(f.Properties.MessageId) > 0 {
mask = mask | flagMessageId
}
if f.Properties.Timestamp != zeroTime {
if !f.Properties.Timestamp.IsZero() {
mask = mask | flagTimestamp
}
if len(f.Properties.Type) > 0 {
Expand Down

0 comments on commit 4a77835

Please sign in to comment.