v0.0.427
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 3m30s
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 3m30s
This commit is contained in:
19
langext/object.go
Normal file
19
langext/object.go
Normal 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
|
||||
}
|
Reference in New Issue
Block a user