S
S
Shumar_Boris2017-05-25 21:10:07
go
Shumar_Boris, 2017-05-25 21:10:07

How to create a variable in go with a name that is written in another variable?

There is a variable of type string. It has a word in it. How to create a variable with the name that is written to the variable?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
Alexander Pavlyuk, 2017-05-25
@pav5000

No, Go is not a scripting language.

A
Andrey Burov, 2017-05-25
@BuriK666

Perhaps you need map[string]interface{}?

D
dinegnet, 2017-05-25
@dinegnet

In static languages, such things are implemented differently:
by the corresponding structures.
if it’s completely unbearable, then with the help of reflection

E
Error 502, 2017-05-25
@NullByte

Why do you need it? the name of the variable in the program will not change anything. the determining factor is its value, and not some name there.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question