I cannot find implementation code of append() or any other builtin functions anywhere? I tried finding the code through godoc and using jump-to-definition feature of IDE's. May be i am looking at wrong places. Could anyone show me the way to see actual implementation?
Asked
Active
Viewed 8,608 times
19
-
If you want to see the builtin API see http://golang.org/src/builtin/builtin.go – Sridhar Aug 03 '15 at 14:51
-
1@sridhar i did. There is no implementation there. – Mayank Patel Aug 03 '15 at 15:07
-
Yes it's the API. The source will probably be written in a combination of C/C++/assembly which may also be open source but you'll have to look a little harder. – Sridhar Aug 03 '15 at 15:15
-
The source is pretty much all in Go, though part of it is in a hardcore-reading form as that part resides in the code generation package. Details in my answer below. – Mathias Dolidon Aug 03 '15 at 16:15
-
1You can check out the Append() example in the following link http://blog.golang.org/slices – Rain Lee Aug 03 '15 at 22:55
1 Answers
15
You may be interested by :
- the code generating bit
append
is in here https://github.com/golang/go/blob/go1.16.7/src/cmd/compile/internal/gc/ssa.go - and
growslice
, used by the former, and that lives in here : https://github.com/golang/go/blob/go1.16.7/src/runtime/slice.go

maroux
- 3,764
- 3
- 23
- 32

Mathias Dolidon
- 3,775
- 1
- 20
- 28