See the last section of this article where it talks about generics - https://blog.gopheracademy.com/advent-2016/advanced-encoding-decoding/
It isn't exactly what you are doing but the same idea should work in your use case. The encoding/decoding code becomes longer but it makes using the data simpler. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.