Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
0006c6859d
|
|||
827b3fc1b7
|
@@ -1,5 +1,5 @@
|
|||||||
package goext
|
package goext
|
||||||
|
|
||||||
const GoextVersion = "0.0.148"
|
const GoextVersion = "0.0.150"
|
||||||
|
|
||||||
const GoextVersionTimestamp = "2023-06-07T17:22:38+0200"
|
const GoextVersionTimestamp = "2023-06-07T17:48:36+0200"
|
||||||
|
@@ -46,10 +46,14 @@ func (pss PrimitiveStringSerializer) ValueToString(v any) (string, error) {
|
|||||||
|
|
||||||
func (pss PrimitiveStringSerializer) ValueFromString(str string, outType reflect.Type) (any, error) {
|
func (pss PrimitiveStringSerializer) ValueFromString(str string, outType reflect.Type) (any, error) {
|
||||||
|
|
||||||
if str == "" {
|
if outType.Kind() == reflect.Ptr && str == "" {
|
||||||
return reflect.Zero(outType).Interface(), nil // = nil.(outType), nil
|
return reflect.Zero(outType).Interface(), nil // = nil.(outType), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if str == "" {
|
||||||
|
return reflect.Zero(outType).Interface(), nil // = <default>(outType), nil
|
||||||
|
}
|
||||||
|
|
||||||
if outType.Kind() == reflect.Ptr {
|
if outType.Kind() == reflect.Ptr {
|
||||||
|
|
||||||
innerValue, err := pss.ValueFromString(str, outType.Elem())
|
innerValue, err := pss.ValueFromString(str, outType.Elem())
|
||||||
|
@@ -4,6 +4,7 @@ import (
|
|||||||
"gogs.mikescher.com/BlackForestBytes/goext/langext"
|
"gogs.mikescher.com/BlackForestBytes/goext/langext"
|
||||||
"gogs.mikescher.com/BlackForestBytes/goext/reflectext"
|
"gogs.mikescher.com/BlackForestBytes/goext/reflectext"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (c *Coll[TData]) init() {
|
func (c *Coll[TData]) init() {
|
||||||
@@ -32,7 +33,13 @@ func (c *Coll[TData]) initFields(prefix string, rval reflect.Value, idxarr []int
|
|||||||
}
|
}
|
||||||
|
|
||||||
bsonkey, found := rsfield.Tag.Lookup("bson")
|
bsonkey, found := rsfield.Tag.Lookup("bson")
|
||||||
if !found || bsonkey == "-" {
|
if !found {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if strings.Contains(bsonkey, ",") {
|
||||||
|
bsonkey = bsonkey[:strings.Index(bsonkey, ",")]
|
||||||
|
}
|
||||||
|
if bsonkey == "-" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user