mirror of https://github.com/1Panel-dev/1Panel
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
326 B
19 lines
326 B
2 years ago
|
package copier
|
||
|
|
||
|
import (
|
||
|
"encoding/json"
|
||
|
|
||
|
"github.com/pkg/errors"
|
||
|
)
|
||
|
|
||
|
func Copy(to, from interface{}) error {
|
||
|
b, err := json.Marshal(from)
|
||
|
if err != nil {
|
||
|
return errors.Wrap(err, "marshal from data err")
|
||
|
}
|
||
|
if err = json.Unmarshal(b, to); err != nil {
|
||
|
return errors.Wrap(err, "unmarshal to data err")
|
||
|
}
|
||
|
return nil
|
||
|
}
|