我有一个并发程序,像这样:
Routine 1()
{
for 30 times
Send string
}
Routine 2 (out <-chan string)
{
for
case str := <- out:
fmt.Println(str)
}
现在,我想从程序1发送一个字符串,例如,字符串+整数+字符串+纳秒级系统时间。有人能帮我实现这个吗?
我有一个并发程序,像这样:
Routine 1()
{
for 30 times
Send string
}
Routine 2 (out <-chan string)
{
for
case str := <- out:
fmt.Println(str)
}
抱歉,我提问得太早了。可以像这样实现:
out <- string + strconv.Itoa(int) + string + strconv.Itoa64(time.Nanoseconds())
感谢。
更新(Go1):strconv.Itoa64
已被替换为 strconv.FormatInt
。
out <- fmt.Sprintf("blah %d blah %d", someint, time.Now().UnixNano())
。 - jimt