【问题标题】:Confusing, what is this inside the channel in Go Routines [closed]令人困惑的是,Go Routines 的通道内是什么 [关闭]
【发布时间】:2021-07-29 03:14:15
【问题描述】:

计划:

package main
import (
"fmt"
)
func main() {
ch := make(chan int)
fmt.Println(ch)
fmt.Println(0xc000062060)
}

输出:

0xc00009e000
824634122336

该输出 (824634122336) 是什么意思? 我认为(0xc00009e000)是一个通道的起始地址。

  • 如果(0xc00009e000 是通道地址)

    • 那请告诉我这是什么 (824634122336)
  • 其他

    • 那么请说出那些输出是什么。

【问题讨论】:

  • 0xc000062060 是十进制的 824634122336。 (所以824634122336 是您调用fmt.Println(0xc000062060) 时看到的输出。是的,打印这样的chan 只会打印它的地址。
  • 哦,谢谢@DarshanRivkaWhittle,我想知道地址,它是什么,为什么会这样,系统对地址的处理方式不同,我们可以用这些地址做什么,它将在哪里有帮助,我想了解有关地址的更多见解,您能帮帮我吗?
  • @Nellai 频道的地址没什么有趣的。你不能从那个地址学到任何东西。

标签: go channel goroutine address-space


【解决方案1】:

0xc00009e000 是一个十六进制值824634122336。所以824634122336 不是频道中的值。

fmt.Println(0x10) //Output: 16

在软件计算中,加“0x”前缀表示十六进制数。

参考这个why-are-hexadecimal-numbers-prefixed-with-0x

【讨论】:

    猜你喜欢
    • 2015-12-07
    • 2010-09-28
    • 2013-01-04
    • 2011-06-07
    • 2014-12-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多