v0.0.427
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 3m30s

This commit is contained in:
2024-04-07 15:10:21 +02:00
parent 678ddd7124
commit 758e5a67b5
4 changed files with 36 additions and 7 deletions

19
langext/object.go Normal file
View File

@@ -0,0 +1,19 @@
package langext
import "encoding/json"
func DeepCopyByJson[T any](v T) (T, error) {
bin, err := json.Marshal(v)
if err != nil {
return *new(T), err
}
var result T
err = json.Unmarshal(bin, &result)
if err != nil {
return *new(T), err
}
return result, nil
}