From 8ea9b3f79f30d1cdc9a37214dc72c676cc7e3582 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Schw=C3=B6rer?= Date: Tue, 15 Jul 2025 13:46:36 +0200 Subject: [PATCH] v0.0.589 improve Equal method of rfctime structs - prevents panic in cmp library --- go.mod | 2 +- go.sum | 2 ++ goextVersion.go | 4 ++-- rfctime/rfc3339.go | 10 ++++++++-- rfctime/rfc3339Nano.go | 10 ++++++++-- rfctime/unix.go | 10 ++++++++-- rfctime/unixMilli.go | 10 ++++++++-- rfctime/unixNano.go | 10 ++++++++-- 8 files changed, 45 insertions(+), 13 deletions(-) diff --git a/go.mod b/go.mod index 8247f91..d751e71 100644 --- a/go.mod +++ b/go.mod @@ -38,7 +38,7 @@ require ( github.com/google/uuid v1.5.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/klauspost/compress v1.18.0 // indirect - github.com/klauspost/cpuid/v2 v2.2.11 // indirect + github.com/klauspost/cpuid/v2 v2.3.0 // indirect github.com/leodido/go-urn v1.4.0 // indirect github.com/mattn/go-colorable v0.1.14 // indirect github.com/mattn/go-isatty v0.0.20 // indirect diff --git a/go.sum b/go.sum index 35c4d84..8c0c250 100644 --- a/go.sum +++ b/go.sum @@ -132,6 +132,8 @@ github.com/klauspost/cpuid/v2 v2.2.10 h1:tBs3QSyvjDyFTq3uoc/9xFpCuOsJQFNPiAhYdw2 github.com/klauspost/cpuid/v2 v2.2.10/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0= github.com/klauspost/cpuid/v2 v2.2.11 h1:0OwqZRYI2rFrjS4kvkDnqJkKHdHaRnCm68/DY4OxRzU= github.com/klauspost/cpuid/v2 v2.2.11/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0= +github.com/klauspost/cpuid/v2 v2.3.0 h1:S4CRMLnYUhGeDFDqkGriYKdfoFlDnMtqTiI/sFzhA9Y= +github.com/klauspost/cpuid/v2 v2.3.0/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0= github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M= github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ= github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI= diff --git a/goextVersion.go b/goextVersion.go index c0a34f7..e3195f8 100644 --- a/goextVersion.go +++ b/goextVersion.go @@ -1,5 +1,5 @@ package goext -const GoextVersion = "0.0.588" +const GoextVersion = "0.0.589" -const GoextVersionTimestamp = "2025-07-11T11:50:29+0200" +const GoextVersionTimestamp = "2025-07-15T13:46:36+0200" diff --git a/rfctime/rfc3339.go b/rfctime/rfc3339.go index c3b5ff0..8ff937c 100644 --- a/rfctime/rfc3339.go +++ b/rfctime/rfc3339.go @@ -4,11 +4,11 @@ import ( "encoding/json" "errors" "fmt" + "git.blackforestbytes.com/BlackForestBytes/goext/langext" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson/bsoncodec" "go.mongodb.org/mongo-driver/bson/bsonrw" "go.mongodb.org/mongo-driver/bson/bsontype" - "git.blackforestbytes.com/BlackForestBytes/goext/langext" "reflect" "time" ) @@ -142,7 +142,13 @@ func (t RFC3339Time) Before(u AnyTime) bool { return t.Time().Before(tt(u)) } -func (t RFC3339Time) Equal(u AnyTime) bool { +func (t *RFC3339Time) Equal(u AnyTime) bool { + if t == nil && u == nil { + return true + } + if t == nil || u == nil { + return false + } return t.Time().Equal(tt(u)) } diff --git a/rfctime/rfc3339Nano.go b/rfctime/rfc3339Nano.go index 5ef7430..dc9bd85 100644 --- a/rfctime/rfc3339Nano.go +++ b/rfctime/rfc3339Nano.go @@ -4,11 +4,11 @@ import ( "encoding/json" "errors" "fmt" + "git.blackforestbytes.com/BlackForestBytes/goext/langext" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson/bsoncodec" "go.mongodb.org/mongo-driver/bson/bsonrw" "go.mongodb.org/mongo-driver/bson/bsontype" - "git.blackforestbytes.com/BlackForestBytes/goext/langext" "reflect" "time" ) @@ -142,7 +142,13 @@ func (t RFC3339NanoTime) Before(u AnyTime) bool { return t.Time().Before(tt(u)) } -func (t RFC3339NanoTime) Equal(u AnyTime) bool { +func (t *RFC3339NanoTime) Equal(u AnyTime) bool { + if t == nil && u == nil { + return true + } + if t == nil || u == nil { + return false + } return t.Time().Equal(tt(u)) } diff --git a/rfctime/unix.go b/rfctime/unix.go index 1030d06..593792a 100644 --- a/rfctime/unix.go +++ b/rfctime/unix.go @@ -4,11 +4,11 @@ import ( "encoding/json" "errors" "fmt" + "git.blackforestbytes.com/BlackForestBytes/goext/langext" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson/bsoncodec" "go.mongodb.org/mongo-driver/bson/bsonrw" "go.mongodb.org/mongo-driver/bson/bsontype" - "git.blackforestbytes.com/BlackForestBytes/goext/langext" "reflect" "strconv" "time" @@ -136,7 +136,13 @@ func (t UnixTime) Before(u AnyTime) bool { return t.Time().Before(tt(u)) } -func (t UnixTime) Equal(u AnyTime) bool { +func (t *UnixTime) Equal(u AnyTime) bool { + if t == nil && u == nil { + return true + } + if t == nil || u == nil { + return false + } return t.Time().Equal(tt(u)) } diff --git a/rfctime/unixMilli.go b/rfctime/unixMilli.go index 6fa48c1..6b9634d 100644 --- a/rfctime/unixMilli.go +++ b/rfctime/unixMilli.go @@ -4,11 +4,11 @@ import ( "encoding/json" "errors" "fmt" + "git.blackforestbytes.com/BlackForestBytes/goext/langext" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson/bsoncodec" "go.mongodb.org/mongo-driver/bson/bsonrw" "go.mongodb.org/mongo-driver/bson/bsontype" - "git.blackforestbytes.com/BlackForestBytes/goext/langext" "reflect" "strconv" "time" @@ -136,7 +136,13 @@ func (t UnixMilliTime) Before(u AnyTime) bool { return t.Time().Before(tt(u)) } -func (t UnixMilliTime) Equal(u AnyTime) bool { +func (t *UnixMilliTime) Equal(u AnyTime) bool { + if t == nil && u == nil { + return true + } + if t == nil || u == nil { + return false + } return t.Time().Equal(tt(u)) } diff --git a/rfctime/unixNano.go b/rfctime/unixNano.go index 44fca52..72e1683 100644 --- a/rfctime/unixNano.go +++ b/rfctime/unixNano.go @@ -4,11 +4,11 @@ import ( "encoding/json" "errors" "fmt" + "git.blackforestbytes.com/BlackForestBytes/goext/langext" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson/bsoncodec" "go.mongodb.org/mongo-driver/bson/bsonrw" "go.mongodb.org/mongo-driver/bson/bsontype" - "git.blackforestbytes.com/BlackForestBytes/goext/langext" "reflect" "strconv" "time" @@ -136,7 +136,13 @@ func (t UnixNanoTime) Before(u AnyTime) bool { return t.Time().Before(tt(u)) } -func (t UnixNanoTime) Equal(u AnyTime) bool { +func (t *UnixNanoTime) Equal(u AnyTime) bool { + if t == nil && u == nil { + return true + } + if t == nil || u == nil { + return false + } return t.Time().Equal(tt(u)) }