我對go很感興趣,並試圖閱讀go函數的實現。我發現這些函數中有一些沒有實現。Go的func追加在哪裏執行?
如追加或致電:
// 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代碼,因爲使用CGO需要一些特別的意見。 這些函數的實現在哪裏?
我相信整個編譯器已被轉換爲Go(自主託管)。如果您正在閱讀舊版本,則可能有幸在最新的版本中找到Go代碼。 – BoppreH
@BoppreH我也聽說過。但是在這裏還沒有實現_append_:[link](https://github.com/golang/go/blob/master/src/builtin/builtin.go) – user1260771