Skip to content

Instantly share code, notes, and snippets.

@lachlan-eagling
Last active October 13, 2019 01:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lachlan-eagling/82d2dffc127ecd61802efbda48f03499 to your computer and use it in GitHub Desktop.
Save lachlan-eagling/82d2dffc127ecd61802efbda48f03499 to your computer and use it in GitHub Desktop.
Blog - Anatomy of a Struct (Basic Struct Memory Example)
package main
import (
"fmt"
"unsafe"
)
type MemoryExample struct {
a int // 8 byte
b int16 // 2 bytes
c bool // 1 bytes
}
func main() {
fmt.Printf("Sizeof MemoryExample: %d", unsafe.Sizeof(MemoryExample{}))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment