mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-18 23:10:25 +08:00
优化界面
This commit is contained in:
24
internal/utils/json.go
Normal file
24
internal/utils/json.go
Normal file
@@ -0,0 +1,24 @@
|
||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||
|
||||
package utils
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"reflect"
|
||||
)
|
||||
|
||||
// JSONClone 使用JSON克隆对象
|
||||
func JSONClone(v interface{}) (interface{}, error) {
|
||||
data, err := json.Marshal(v)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var nv = reflect.New(reflect.TypeOf(v).Elem()).Interface()
|
||||
err = json.Unmarshal(data, nv)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return nv, nil
|
||||
}
|
||||
Reference in New Issue
Block a user