In Go, you want to do a conversion.
Conversions
Transformations are expressions of the form T(x) , where T is a type and x is an expression that can be converted to type T
Conversion = Type "(" Expression ")" .
The variable x value can be converted to type T in any of these cases:
x assigned to Tx type and T have the same base types.x type and T are unnamed pointer types, and their base pointer types have the same base types.x type and T are integers or floating point.x type and T are complex types.x is an integer or has the type []byte or []rune , and T is a string type.x is a string, and T is []byte or []rune .
You want to convert x , of type int , int32 or int64 , to T type rune , an alias for type int32 . x and T are integer types.
Therefore, T(x) allowed and written rune(x) , for your example, c = rune(i) .
source share