zaRRoc
zaRRoc

Reputation: 403

Golang's builtin function implementations

I am unable to find the implementation of built-in functions.

In builtin.go, this is what I found:

// The copy built-in function copies elements from a source slice 
into a
// destination slice. (As a special case, it also will copy bytes 
from a
// string to a slice of bytes.) The source and destination may 
overlap. Copy
// returns the number of elements copied, which will be the minimum 
of
// len(src) and len(dst).
func copy(dst, src []Type) int

Where is the actual implementation of the built-in functions?

Upvotes: 6

Views: 3239

Answers (1)

Thundercat
Thundercat

Reputation: 121049

The builtin package serves as documentation only. The package does not contain implementations of the functions.

The builtin functions are implemented by a combination of the compiler and functions internal to the runtime package.

You can find the low-level implementation of copy in the memmove* files in the runtime source directory .

Upvotes: 3

Related Questions