I am new to the Golang, so I apologize if this question is too naive. I looked around, but could not find the answer to my main question.
Suppose I have a specific structure and methods, as shown below.
type MyData struct{ field1 string field2 int } func(a MyData) OperatorOnString() string{ return a.field1.(string) } func(a MyData) OperatorOnInt() int{ return a.field2.(int) }
My question is: can I type and return, and not fulfill the statement? From what I have learned so far, this statement is used for type interface data. But in this case, I have a specific type. Should I use a statement, or can I do something like return int(a.field2) . I know this example is trivial, but the point that I confused is when to use between two types of conversions. Or is there some kind of golian idiom here?
thanks
Minty source share