mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2024-11-15 20:20:11 +08:00
18 lines
326 B
Go
18 lines
326 B
Go
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
|
|
}
|