DEV Community

Pandademic
Pandademic

Posted on • Edited on

2 2

Go : Creating a variable which has the name of another variables value

Is this possible:
something like

one := "Hello"
var {substitute the value of 'one' here} = "did it work"
Enter fullscreen mode Exit fullscreen mode

I tried:

one := "hewo"
string(one) :=  "but this doesn't work either"
Enter fullscreen mode Exit fullscreen mode

Do you know how to do this or if this is even possible?

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay