Мне очень интересно идти и пытаться прочитать реализации функции go. Я обнаружил, что некоторые из этих функций не имеют реализаций.Где реализация func append в Go?
Такие, как Append или звоните:
// The append built-in function appends elements to the end of a slice. If
// it has sufficient capacity, the destination is resliced to accommodate the
// new elements. If it does not, a new underlying array will be allocated.
// Append returns the updated slice. It is therefore necessary to store the
// result of append, often in the variable holding the slice itself:
// slice = append(slice, elem1, elem2)
// slice = append(slice, anotherSlice...)
// As a special case, it is legal to append a string to a byte slice, like this:
// slice = append([]byte("hello "), "world"...)
func append(slice []Type, elems ...Type) []Type
// call calls fn with a copy of the n argument bytes pointed at by arg.
// After fn returns, reflectcall copies n-retoffset result bytes
// back into arg+retoffset before returning. If copying result bytes back,
// the caller must pass the argument frame type as argtype, so that
// call can execute appropriate write barriers during the copy.
func call(argtype *rtype, fn, arg unsafe.Pointer, n uint32, retoffset uint32)
Это, похоже, не вызывающему код C, потому что с помощью ОЦП нуждается в особых комментариях. Где реализуются эти функции?
Я считаю, что весь компилятор был переведен на Go (self hosting). Если вы читаете старую версию, вам может повезти найти код Go в новейших версиях. – BoppreH
@BoppreH Я тоже это слышал.Но реализация _append_ по-прежнему отсутствует: [link] (https://github.com/golang/go/blob/master/src/builtin/builtin.go) – user1260771