Skip to content

Instantly share code, notes, and snippets.

@gghez
Created January 1, 2020 20:54
Show Gist options
  • Select an option

  • Save gghez/a319024b6512c7b44ed3687580f7c86b to your computer and use it in GitHub Desktop.

Select an option

Save gghez/a319024b6512c7b44ed3687580f7c86b to your computer and use it in GitHub Desktop.

Revisions

  1. gghez created this gist Jan 1, 2020.
    23 changes: 23 additions & 0 deletions main.go
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    import (
    "unsafe"
    "fmt"
    )

    type A struct {
    a string
    b bool
    c bool
    d string
    }

    type B struct {
    a string
    b bool
    c string
    d bool
    }

    func main(){
    fmt.Printf("well aligned size: %d\n", unsafe.Sizeof(A{}))
    fmt.Printf("random aligned size: %d\n", unsafe.Sizeof(B{}))
    }