I really thought this would be as simple as :
string(myInt)
It appears not.
I am writing a function which takes a slice of ints, and appends each one to a string - and adds a separator between each one. Here is my code.
func(xis *Int16Slice) ConvertToStringWithSeparator(separator string) string{
var buffer bytes.Buffer
for i, value := range *xis{
buffer.WriteString(string(value))
if i != len(*xis) -1 {
buffer.WriteString(separator)
}
}
return buffer.String()
}
Please read the sentence below. This is not a duplicate of How to convert an int value to string in Go? - because : I am aware of things like the strconv.Itoa function, but it appears as though that will only work on "regular" ints. It will not support an int16