Where can I find string implementation?

635 views
Skip to first unread message

Nan Xiao

unread,
Mar 22, 2016, 11:52:28 PM3/22/16
to golang-nuts
Hi all,

From this post, I can see the string implementation is in https://golang.org/src/runtime/runtime.h previously:  

    struct String
    {
        byte*   str;
        int32   len;
    };

But now, https://golang.org/src/runtime/runtime.h has gone. I try to grep "string struct" in the golang source code,
but can't find string definition.

Where can I find string implementation now? Thanks in advance!

Best Regards
Nan Xiao

Jesse McNelis

unread,
Mar 23, 2016, 12:36:43 AM3/23/16
to Nan Xiao, golang-nuts

Konstantin Khomoutov

unread,
Mar 23, 2016, 7:38:34 AM3/23/16
to Nan Xiao, golang-nuts
On Tue, 22 Mar 2016 20:52:28 -0700 (PDT)
Nan Xiao <xiaona...@gmail.com> wrote:

> From this post
> <https://groups.google.com/forum/#!topic/golang-nuts/ZRKSJ3GPkLw>, I
> can see the string implementation is in
> https://golang.org/src/runtime/runtime.h previously:
>
> struct String
> {
> byte* str;
> int32 len;
> };
>
> But now, https://golang.org/src/runtime/runtime.h has gone. I try to
> grep "string struct" in the golang source code,
> but can't find string definition.
>
> Where can I find string implementation now? Thanks in advance!

Go has been re-written in Go starting with 1.5, so to say, in order to
build Go >= 1.5 from sources you now need to have Go 1.4 or higher
installed and working.

Consequently, string manipulation has been re-written in Go as well
and hence there's no more C's header files for that.

I'd say the file you need is {src}/runtime/string.go assuming the {src}
is the directory with the Go's source code.
Reply all
Reply to author
Forward
0 new messages