问题:这行代码
str := string(line)
line是 []byte 类型, 我想查看string函数的实现, 在哪里可以看到?
点击string函数 跳转到
// string is the set of all strings of 8-bit bytes, conventionally but not
// necessarily representing UTF-8-encoded text. A string may be empty, but
// not nil. Values of string type are immutable.
type string string
找不到string函数
string() 函数的具体实现与调用它的参数类型有关,与 go 版本也有关。
举个例子,以下代码
你可以运行
go build -gcflags -S xxx.go
查看汇编信息