Created
May 9, 2022 09:40
-
-
Save hindungWang/c40f2a44fbbef1d0a1616c70f531fd59 to your computer and use it in GitHub Desktop.
DeepCopy of type map[string]interface{}
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// +k8s:deepcopy-gen=true | |
type MapStringInterface map[string]interface{} | |
func (m *MapStringInterface) DeepCopy() *MapStringInterface { | |
var buf bytes.Buffer | |
enc := gob.NewEncoder(&buf) | |
dec := gob.NewDecoder(&buf) | |
err := enc.Encode(m) | |
if err != nil { | |
logrus.Errorf("error while deep copying MapStringInterface %v", err) | |
return nil | |
} | |
var copy MapStringInterface | |
err = dec.Decode(©) | |
if err != nil { | |
logrus.Errorf("error while deep copying MapStringInterface %v", err) | |
return nil | |
} | |
return © | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment