Похожие чаты

Can someone explain this to me? bytes := []byte{'H', 'e', 'l',

'l', 'o'}
str := string(bytes)

My understanding is string here is not a function, but a feature of the language (casting).

I am interested in knowing exactly how a slice of bytes is converted into a string, not on a theoretical level, but on a source code line-by-line level.

https://github.com/golang/go/blob/d5c5808534f0ad97333b1fd5fff81998f44986fe/src/runtime/string.go#L81 Would this be the place?

And if so, why is it a function? I thought it wouldn't be a function.

I think I don't understand the difference between stdlib and compiler

6 ответов

19 просмотров

The compiler will replace the casting call with this function internally

What did you think it would be if not a function?

Liλn-🌻 Автор вопроса
Thomas
What did you think it would be if not a function?

I don't really know, that's why I am asking! :D Maybe it could be some machine code idk

Liλn 🌻
I don't really know, that's why I am asking! :D M...

any function eventually ends up being machine code :D

Похожие вопросы

Обсуждают сегодня

Карта сайта