I have a struct
that is designed like this:
type UrlData struct {
As int
Iso string
}
I instantiate it and after that I read a text file (see below) so as to check if certain struct field is equal to a value from the txt file (yes, I know that it would be much easier to compare explicitly, but reading the data from file is the requirement to be met)
The txt file has the following format:
as 646
iso us
When reading the txt file, I want to know if the *UrlData.As field (in the instantiated item) is equal to the value from file, i.e. 646.
The problem is I don't know how to match current field from the txt file with the name of the struct field. What is the most adequate way to do that?