i := 123
s := string(i)
s is 'E', but what I want is "123"
Please tell me how can I get "123".
And in Java, I can do in this way:
String s = "ab" + "c" // s is "abc"
how can I concat
two strings in Go?
convertersgointstring
i := 123
s := string(i)
s is 'E', but what I want is "123"
Please tell me how can I get "123".
And in Java, I can do in this way:
String s = "ab" + "c" // s is "abc"
how can I concat
two strings in Go?
Best Answer
Use the
strconv
package'sItoa
function.For example:
You can concat strings simply by
+
'ing them, or by using theJoin
function of thestrings
package.