Golang shorts #4 — Reflect like a boss

Today I found the nicest way to walk through on an unknown type and put data into. Thanks for the library Elastic and the author olivere.

Thanks for the changes in the gist file for Oliver Eilhard to make it more simple and straightforward.

So the main thing what happens here, the Result is an array of JSON content. The Each method gets a type what it can use to translate this JSONs and basically returns the slice of translated data.

I’m very happy to found this solution because many times I struggle with the same problem and I tried many other solutions, but it’s way more better than all of mine.

Like what you read? Give PumpkinSeed a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.