dongmuzhan4705
2011-12-03 17:42
浏览 87
已采纳

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

I have concurrent routine like this,

Routine 1()
{
for 30 times
Send string
}

Routine 2 (out <-chan string)
{
for
case str := <- out:
        fmt.Println(str)
}

Now, I want to send from routine 1 string like, string + int + string + system time in nanosecond. Can anybody help me how can I achieve this.

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

  • doushi3803 2011-12-03 18:03
    最佳回答

    Sorry, I asked it too early. It is possible like this:

    out <- string + strconv.Itoa(int) + string + strconv.Itoa64(time.Nanoseconds())
    

    Thanks.


    Update (Go1): strconv.Itoa64 has been replaced by strconv.FormatInt.

    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题