DEV Community


Posted on


Convert var string struct key to struct key



I have a map (string) of "tag" to convert "words" into a text
this list of "Tags" must be replaced by values coming from a structure

var users struc {
login String
json:" options "
passwd String
json:" options "
var folders struc {
arch String
json:" folders "
dest String
json:" folders "`

var TAGS = map [string] string {
"{login}": "users.login",
"{passwd}": "users.passwd",
"{archive}": "folders.arch",
"{dest}": "folders.dest",

To do something like this:
var test = "Name = {login} archive = {archive} destination = {dest} / {login}"
var realTest = ReplaceTag (test, & TAGS)

I don't know how to convert the strings from the value to the real value of the structure.
I know how to do it directly but not when it is in the form of a string

thank you in advance

Latest comments (0)

Timeless DEV post...

Git Concepts I Wish I Knew Years Ago

The most used technology by developers is not Javascript.

It's not Python or HTML.

It hardly even gets mentioned in interviews or listed as a pre-requisite for jobs.

I'm talking about Git and version control of course.

One does not simply learn git