Compare commits
	
		
			2 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 890e16241d | |||
| b9d0348735 | 
| @@ -9,6 +9,7 @@ import ( | |||||||
| 	"go.mongodb.org/mongo-driver/bson" | 	"go.mongodb.org/mongo-driver/bson" | ||||||
| 	"go.mongodb.org/mongo-driver/bson/primitive" | 	"go.mongodb.org/mongo-driver/bson/primitive" | ||||||
| 	"gogs.mikescher.com/BlackForestBytes/goext/langext" | 	"gogs.mikescher.com/BlackForestBytes/goext/langext" | ||||||
|  | 	"math" | ||||||
| 	"strconv" | 	"strconv" | ||||||
| 	"strings" | 	"strings" | ||||||
| 	"time" | 	"time" | ||||||
| @@ -667,6 +668,28 @@ func (v MetaValue) rawValueForJson() any { | |||||||
| 		} | 		} | ||||||
| 		return v.Value.(EnumWrap).ValueString | 		return v.Value.(EnumWrap).ValueString | ||||||
| 	} | 	} | ||||||
|  | 	if v.DataType == MDTFloat32 { | ||||||
|  | 		if math.IsNaN(float64(v.Value.(float32))) { | ||||||
|  | 			return "float64::NaN" | ||||||
|  | 		} else if math.IsInf(float64(v.Value.(float32)), +1) { | ||||||
|  | 			return "float64::+inf" | ||||||
|  | 		} else if math.IsInf(float64(v.Value.(float32)), -1) { | ||||||
|  | 			return "float64::-inf" | ||||||
|  | 		} else { | ||||||
|  | 			return v.Value | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 	if v.DataType == MDTFloat64 { | ||||||
|  | 		if math.IsNaN(v.Value.(float64)) { | ||||||
|  | 			return "float64::NaN" | ||||||
|  | 		} else if math.IsInf(v.Value.(float64), +1) { | ||||||
|  | 			return "float64::+inf" | ||||||
|  | 		} else if math.IsInf(v.Value.(float64), -1) { | ||||||
|  | 			return "float64::-inf" | ||||||
|  | 		} else { | ||||||
|  | 			return v.Value | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
| 	return v.Value | 	return v.Value | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,5 +1,5 @@ | |||||||
| package goext | package goext | ||||||
|  |  | ||||||
| const GoextVersion = "0.0.378" | const GoextVersion = "0.0.380" | ||||||
|  |  | ||||||
| const GoextVersionTimestamp = "2024-01-16T15:04:10+0100" | const GoextVersionTimestamp = "2024-01-22T12:33:41+0100" | ||||||
|   | |||||||
							
								
								
									
										21
									
								
								langext/must.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								langext/must.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,21 @@ | |||||||
|  | package langext | ||||||
|  |  | ||||||
|  | // Must returns a value and panics on error | ||||||
|  | // | ||||||
|  | // Usage: Must(methodWithError(...)) | ||||||
|  | func Must[T any](v T, err error) T { | ||||||
|  | 	if err != nil { | ||||||
|  | 		panic(err) | ||||||
|  | 	} | ||||||
|  | 	return v | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // MustBool returns a value and panics on missing | ||||||
|  | // | ||||||
|  | // Usage: MustBool(methodWithOkayReturn(...)) | ||||||
|  | func MustBool[T any](v T, ok bool) T { | ||||||
|  | 	if !ok { | ||||||
|  | 		panic("not ok") | ||||||
|  | 	} | ||||||
|  | 	return v | ||||||
|  | } | ||||||
		Reference in New Issue
	
	Block a user