#Cast string as a datatype?

3 messages · Page 1 of 1 (latest)

tight fractal
#

you’re using the syntax of type assertion but there is no interfaces
what’s the expected input and output?

icy hollow
#

you can't do that, go is a statically typed and compiled language what you are asking for require parsing types at runtime like python does.

polar haven
#

Go does not support having types as a value as seen in some other languages. Basically because the name of a type by itself is not an expression. The closest thing you can is using the reflect package, and even then it's not quite what you're looking for.