Standard library / go/types
go/types.Sizes
Interface modeling alignment, field offsets and sizes for unsafe operations. Expected stdout: '8\n'.
Formal Syntax & Structure
go syntaxgo
type Sizes interface { Alignof(T Type) int64
Offsetsof(fields []*Var) []int64
Sizeof(T Type) int64}Working Example
Example Snippetgo
package main
import ( "fmt" "go/types")
func main() { var s types.Sizes = types.SizesFor("gc", "amd64") fmt.Println(s.Sizeof(types.Typ[types.Int]))}