github.com/traefik/yaegi@v0.15.1/_test/unsafe5.go (about)

     1  package main
     2  
     3  import (
     4  	"math/bits"
     5  	"unsafe"
     6  )
     7  
     8  const WSize = bits.UintSize / 8
     9  
    10  type S struct {
    11  	X int
    12  	Y int
    13  	Z int
    14  }
    15  
    16  func main() {
    17  	x := S{}
    18  	size := unsafe.Sizeof(x) / WSize
    19  	align := unsafe.Alignof(x.Y) / WSize
    20  	offset := unsafe.Offsetof(x.Z) / WSize
    21  
    22  	println(size, align, offset)
    23  }
    24  
    25  // Output:
    26  // 3 1 2