Compare commits

..

3 Commits

Author SHA1 Message Date
dce6f634b1 v0.0.613 Add function to convert RFC3339Time To RFC3339NanoTime. Add function to shuffle array
Some checks failed
Build Docker and Deploy / Run goext test-suite (push) Failing after 1m37s
2025-11-05 14:48:04 +01:00
833f74427f Add ToNano method to convert RFC3339Time to RFC3339NanoTime 2025-11-05 14:45:47 +01:00
535a699584 Add ArrShuffle function to shuffle array elements 2025-11-05 14:45:38 +01:00
3 changed files with 19 additions and 4 deletions

View File

@@ -1,5 +1,5 @@
package goext package goext
const GoextVersion = "0.0.612" const GoextVersion = "0.0.613"
const GoextVersionTimestamp = "2025-11-02T23:14:31+0100" const GoextVersionTimestamp = "2025-11-05T14:48:04+0100"

View File

@@ -3,6 +3,7 @@ package langext
import ( import (
"errors" "errors"
"fmt" "fmt"
"math/rand"
"reflect" "reflect"
) )
@@ -608,3 +609,12 @@ func ArrGroupBy[T1 any, T2 comparable](arr []T1, groupfunc func(v T1) T2) map[T2
return r return r
} }
func ArrShuffle[T any](arr []T) []T {
for i := range arr {
j := rand.Intn(i + 1)
arr[i], arr[j] = arr[j], arr[i]
}
return arr
}

View File

@@ -4,13 +4,14 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"reflect"
"time"
"git.blackforestbytes.com/BlackForestBytes/goext/langext" "git.blackforestbytes.com/BlackForestBytes/goext/langext"
"go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/bsoncodec" "go.mongodb.org/mongo-driver/bson/bsoncodec"
"go.mongodb.org/mongo-driver/bson/bsonrw" "go.mongodb.org/mongo-driver/bson/bsonrw"
"go.mongodb.org/mongo-driver/bson/bsontype" "go.mongodb.org/mongo-driver/bson/bsontype"
"reflect"
"time"
) )
type RFC3339Time time.Time type RFC3339Time time.Time
@@ -263,3 +264,7 @@ func NewRFC3339Ptr(t *time.Time) *RFC3339Time {
func NowRFC3339() RFC3339Time { func NowRFC3339() RFC3339Time {
return RFC3339Time(time.Now()) return RFC3339Time(time.Now())
} }
func (t RFC3339Time) ToNano() RFC3339NanoTime {
return NewRFC3339Nano(t.Time())
}