mirror of
https://github.com/k3s-io/k3s.git
synced 2024-06-07 19:41:36 +00:00
30 lines
755 B
Go
30 lines
755 B
Go
package goStrongswanVici
|
|
|
|
import (
|
|
"encoding/json"
|
|
)
|
|
|
|
//concrete data type to general data type
|
|
// concrete data type like *Version
|
|
// general data type include map[string]interface{} []string string
|
|
// TODO make it faster
|
|
func ConvertToGeneral(concrete interface{}, general interface{}) (err error) {
|
|
b, err := json.Marshal(concrete)
|
|
if err != nil {
|
|
return
|
|
}
|
|
return json.Unmarshal(b, general)
|
|
}
|
|
|
|
// general data type to concrete data type
|
|
// concrete data type like *Version
|
|
// general data type include map[string]interface{} []string string
|
|
// TODO make it faster
|
|
func ConvertFromGeneral(general interface{}, concrete interface{}) (err error) {
|
|
b, err := json.Marshal(general)
|
|
if err != nil {
|
|
return
|
|
}
|
|
return json.Unmarshal(b, concrete)
|
|
}
|