feat: replace pcopy with jinzhu/copier for deep copy functionality

This commit is contained in:
CaIon
2025-08-26 13:40:41 +08:00
parent e23f01f8d5
commit 1cc07546cb
3 changed files with 6 additions and 59 deletions

View File

@@ -2,7 +2,8 @@ package common
import (
"fmt"
"github.com/antlabs/pcopy"
"github.com/jinzhu/copier"
)
func DeepCopy[T any](src *T) (*T, error) {
@@ -10,12 +11,9 @@ func DeepCopy[T any](src *T) (*T, error) {
return nil, fmt.Errorf("copy source cannot be nil")
}
var dst T
err := pcopy.Copy(&dst, src)
err := copier.CopyWithOption(&dst, src, copier.Option{DeepCopy: true, IgnoreEmpty: false})
if err != nil {
return nil, err
}
if &dst == nil {
return nil, fmt.Errorf("copy result cannot be nil")
}
return &dst, nil
}