In Go, using interfaces is the only way to return multiple types in the “dynamic” way you’re asking for. A function that returns interface{}
will assert any returned value to interface{}
, but you can use a type switch to get the original type back out. This tutorial can explain how that works better than I can