Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
cd68af8e66
|
|||
113d838876
|
170
dataext/tuple.go
Normal file
170
dataext/tuple.go
Normal file
@@ -0,0 +1,170 @@
|
||||
package dataext
|
||||
|
||||
type ValueGroup interface {
|
||||
TupleLength() int
|
||||
TupleValues() []any
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
type Single[T1 any] struct {
|
||||
V1 T1
|
||||
}
|
||||
|
||||
func (s Single[T1]) TupleLength() int {
|
||||
return 1
|
||||
}
|
||||
|
||||
func (s Single[T1]) TupleValues() []any {
|
||||
return []any{s.V1}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
type Tuple[T1 any, T2 any] struct {
|
||||
V1 T1
|
||||
V2 T2
|
||||
}
|
||||
|
||||
func (t Tuple[T1, T2]) TupleLength() int {
|
||||
return 2
|
||||
}
|
||||
|
||||
func (t Tuple[T1, T2]) TupleValues() []any {
|
||||
return []any{t.V1, t.V2}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
type Triple[T1 any, T2 any, T3 any] struct {
|
||||
V1 T1
|
||||
V2 T2
|
||||
V3 T3
|
||||
}
|
||||
|
||||
func (t Triple[T1, T2, T3]) TupleLength() int {
|
||||
return 3
|
||||
}
|
||||
|
||||
func (t Triple[T1, T2, T3]) TupleValues() []any {
|
||||
return []any{t.V1, t.V2, t.V3}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
type Quadruple[T1 any, T2 any, T3 any, T4 any] struct {
|
||||
V1 T1
|
||||
V2 T2
|
||||
V3 T3
|
||||
V4 T4
|
||||
}
|
||||
|
||||
func (t Quadruple[T1, T2, T3, T4]) TupleLength() int {
|
||||
return 4
|
||||
}
|
||||
|
||||
func (t Quadruple[T1, T2, T3, T4]) TupleValues() []any {
|
||||
return []any{t.V1, t.V2, t.V3, t.V4}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
type Quintuple[T1 any, T2 any, T3 any, T4 any, T5 any] struct {
|
||||
V1 T1
|
||||
V2 T2
|
||||
V3 T3
|
||||
V4 T4
|
||||
V5 T5
|
||||
}
|
||||
|
||||
func (t Quintuple[T1, T2, T3, T4, T5]) TupleLength() int {
|
||||
return 5
|
||||
}
|
||||
|
||||
func (t Quintuple[T1, T2, T3, T4, T5]) TupleValues() []any {
|
||||
return []any{t.V1, t.V2, t.V3, t.V4, t.V5}
|
||||
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
type Sextuple[T1 any, T2 any, T3 any, T4 any, T5 any, T6 any] struct {
|
||||
V1 T1
|
||||
V2 T2
|
||||
V3 T3
|
||||
V4 T4
|
||||
V5 T5
|
||||
V6 T6
|
||||
}
|
||||
|
||||
func (t Sextuple[T1, T2, T3, T4, T5, T6]) TupleLength() int {
|
||||
return 6
|
||||
}
|
||||
|
||||
func (t Sextuple[T1, T2, T3, T4, T5, T6]) TupleValues() []any {
|
||||
return []any{t.V1, t.V2, t.V3, t.V4, t.V5, t.V6}
|
||||
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
type Septuple[T1 any, T2 any, T3 any, T4 any, T5 any, T6 any, T7 any] struct {
|
||||
V1 T1
|
||||
V2 T2
|
||||
V3 T3
|
||||
V4 T4
|
||||
V5 T5
|
||||
V6 T6
|
||||
V7 T7
|
||||
}
|
||||
|
||||
func (t Septuple[T1, T2, T3, T4, T5, T6, T7]) TupleLength() int {
|
||||
return 7
|
||||
}
|
||||
|
||||
func (t Septuple[T1, T2, T3, T4, T5, T6, T7]) TupleValues() []any {
|
||||
return []any{t.V1, t.V2, t.V3, t.V4, t.V5, t.V6, t.V7}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
type Octuple[T1 any, T2 any, T3 any, T4 any, T5 any, T6 any, T7 any, T8 any] struct {
|
||||
V1 T1
|
||||
V2 T2
|
||||
V3 T3
|
||||
V4 T4
|
||||
V5 T5
|
||||
V6 T6
|
||||
V7 T7
|
||||
V8 T8
|
||||
}
|
||||
|
||||
func (t Octuple[T1, T2, T3, T4, T5, T6, T7, T8]) TupleLength() int {
|
||||
return 8
|
||||
}
|
||||
|
||||
func (t Octuple[T1, T2, T3, T4, T5, T6, T7, T8]) TupleValues() []any {
|
||||
return []any{t.V1, t.V2, t.V3, t.V4, t.V5, t.V6, t.V7, t.V8}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
type Nonuple[T1 any, T2 any, T3 any, T4 any, T5 any, T6 any, T7 any, T8 any, T9 any] struct {
|
||||
V1 T1
|
||||
V2 T2
|
||||
V3 T3
|
||||
V4 T4
|
||||
V5 T5
|
||||
V6 T6
|
||||
V7 T7
|
||||
V8 T8
|
||||
V9 T9
|
||||
}
|
||||
|
||||
func (t Nonuple[T1, T2, T3, T4, T5, T6, T7, T8, T9]) TupleLength() int {
|
||||
return 9
|
||||
}
|
||||
|
||||
func (t Nonuple[T1, T2, T3, T4, T5, T6, T7, T8, T9]) TupleValues() []any {
|
||||
return []any{t.V1, t.V2, t.V3, t.V4, t.V5, t.V6, t.V7, t.V8, t.V9}
|
||||
}
|
@@ -112,13 +112,6 @@ func (b *Builder) WithMessage(msg string) *Builder {
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
func (b *Builder) WithStackSkip(stacktraceskip int) *Builder {
|
||||
b.errorData.Caller = callername(stacktraceskip)
|
||||
return b
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// Err changes the Severity to ERROR (default)
|
||||
// The error will be:
|
||||
//
|
||||
|
@@ -4,10 +4,7 @@ import (
|
||||
"github.com/rs/xid"
|
||||
"github.com/rs/zerolog"
|
||||
"gogs.mikescher.com/BlackForestBytes/goext/langext"
|
||||
"gogs.mikescher.com/BlackForestBytes/goext/rext"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
@@ -80,10 +77,7 @@ func (ee *ExErr) As(target any) bool {
|
||||
}
|
||||
|
||||
func (ee *ExErr) Log(evt *zerolog.Event) {
|
||||
backup := zerolog.CallerMarshalFunc
|
||||
zerolog.CallerMarshalFunc = customZerologCallerMarshalFunc
|
||||
evt.Msg(ee.FormatLog(LogPrintFull))
|
||||
zerolog.CallerMarshalFunc = backup
|
||||
}
|
||||
|
||||
func (ee *ExErr) FormatLog(lvl LogPrintLevel) string {
|
||||
@@ -170,10 +164,7 @@ func (ee *ExErr) FormatLog(lvl LogPrintLevel) string {
|
||||
}
|
||||
|
||||
func (ee *ExErr) ShortLog(evt *zerolog.Event) {
|
||||
backup := zerolog.CallerMarshalFunc
|
||||
zerolog.CallerMarshalFunc = customZerologCallerMarshalFunc
|
||||
ee.Meta.Apply(evt).Msg(ee.FormatLog(LogPrintShort))
|
||||
zerolog.CallerMarshalFunc = backup
|
||||
}
|
||||
|
||||
// RecursiveMessage returns the message to show
|
||||
@@ -305,10 +296,3 @@ func (ee *ExErr) equalsDirectProperties(other *ExErr) bool {
|
||||
func newID() string {
|
||||
return xid.New().String()
|
||||
}
|
||||
|
||||
var regexZerologCallerClean = rext.W(regexp.MustCompile(`^(\.\./)*/?go/pkg/mod/gogs\.(mikescher|blackforestbytes)\.(com|de)/!black!forest!bytes/?`))
|
||||
|
||||
func customZerologCallerMarshalFunc(pc uintptr, file string, line int) string {
|
||||
file = regexZerologCallerClean.ReplaceAll(file, "", true)
|
||||
return file + ":" + strconv.Itoa(line)
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
package goext
|
||||
|
||||
const GoextVersion = "0.0.253"
|
||||
const GoextVersion = "0.0.255"
|
||||
|
||||
const GoextVersionTimestamp = "2023-08-22T10:36:35+0200"
|
||||
const GoextVersionTimestamp = "2023-08-24T09:47:32+0200"
|
||||
|
Reference in New Issue
Block a user