Created
February 28, 2017 00:40
-
-
Save notzippy/3ff69611e6b97b3a769ff6e578bf8ff1 to your computer and use it in GitHub Desktop.
The fun golang laws of reflection - Create a new structure from a pointer using reflection. The returned interface is an instantiated not empty
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
Using the passed in pointer to an interface create a new instantiated structure (not an empty address) | |
func Update(foo interface{}) { | |
result := reflect.New(reflect.ValueOf(update).Elem().Type()).Interface() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment