Skip to content

When storing a value in a Go interface allocates memory on the heap.

License

Notifications You must be signed in to change notification settings

akutz/go-interface-values

Repository files navigation

Go interface values

This repository deep dives Go interface values, what they are, how they work, and when storing a value in a Go interface allocates memory on the heap.

  • Labs: a step-by-step walkthrough of the topic
  • FAQ: answers to frequently asked questions
  • Links: links to related reference material
  • Thanks: it takes a community
  • Appendix: in-repo reference material

Labs

  1. Prerequisites: how to get from here to there
  2. Interface values: whatever you do, do not call it "boxing"
  3. Escape analysis: to malloc or not to malloc
  4. Missing mallocs: there's a heap of missing memory
  5. Lessons learned: key takeaways

FAQ

What does the Q suffix for instructions like MOVQ and LEAQ mean?

Please refer to this answer from the assembly section in the appendix.

What is the x86 assembly instruction CALL actually calling?

Please refer to this answer from the assembly section in the appendix.

Where is the CALL instruction in ARM assembly?

Please refer to this answer from the assembly section in the appendix.

What is the hack directory and the files inside of it?

The hack directory is a convention I picked up from working on Kubernetes and projects related to Kuberentes. The directory contains scripts useful to the project, but not a core piece of the project itself. For example:

Links

Thanks

  • Many thanks to reddit user nikandfor for their response to my post on this topic. Without that initial work, I am not sure this repository would exist today.
  • My gratitude to Crypto Jones from Gopher Slack for keeping me honest about "boxing." 😃
  • My colleague Michael Gasch who spent a lot of time proofreading this repository. Hear that y'all? Any mistakes you find? Totally Michael's fault! 😃
  • Andrew Williams, another co-worker, who did not judge me when he helpfully explained cache lines.
  • The first person who offered to help me dig into the assembly, Kevin Grittner!
  • Several of my colleagues who directed me to a Trie structure for the repository's bespoke test framework:
    • Michal Jankowski
    • Zhanghe Liu
    • Yiyi Zhou
    • Mayank Bhatt
    • Arunesh Pandey

Appendix

  • Assembly: reference section for go asm

About

When storing a value in a Go interface allocates memory on the heap.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published