Add StructToStruct

This commit is contained in:
George Suntres
2026-03-29 13:12:53 -04:00
parent 434ecef67a
commit 65eec3c3b1
4 changed files with 31 additions and 1 deletions

View File

@@ -4,10 +4,15 @@ import (
"log"
"reflect"
"strings"
"github.com/go-viper/mapstructure/v2"
"go.mongodb.org/mongo-driver/v2/bson"
)
func StructToStruct(source any, target any) {
mapstructure.Decode(source, &target)
}
// StructToMapRecursive given a struct or a primitive will return the equivalent
// map[string]any of the struct or the primitive as is.
func StructToMapRecursive(obj any) any {