在Go中将int和long转换为字符串

Arp*_*sss 6 go

我有这样的并发例程,

Routine 1()
{
for 30 times
Send string
}

Routine 2 (out <-chan string)
{
for
case str := <- out:
        fmt.Println(str)
}
Run Code Online (Sandbox Code Playgroud)

现在,我想从例程1字符串发送,如string + int + string +系统时间,以纳秒为单位.任何人都可以帮助我如何实现这一目标.

Arp*_*sss 9

对不起,我太早问了.有可能这样:

out <- string + strconv.Itoa(int) + string + strconv.Itoa64(time.Nanoseconds())
Run Code Online (Sandbox Code Playgroud)

谢谢.


更新(Go1):strconv.Itoa64已被替换为strconv.FormatInt.

  • 或者像这样:`out < - fmt.Sprintf("blah%d blah%d",someint,time.Nanoseconds())` (4认同)