Standard library / go/types

go/types.SizesFor()

Returns compiler- and architecture-specific type sizes, or nil for an unsupported combination. Expected stdout: '4 true\n'.

Formal Syntax & Structure

go syntaxgo
func SizesFor(compiler, arch string) Sizes

Parameters & Attributes

NameTypeDescription
compilerstringInput to the operation as described above.
archstringInput to the operation as described above.

Return Value

Sizes

Returns compiler- and architecture-specific type sizes, or nil for an unsupported combination.

Working Example

Example Snippetgo
package main
import (  "fmt"  "go/types")
func main() {  s := types.SizesFor("gc", "386")  fmt.Println(s.Sizeof(types.Typ[types.Int]), types.SizesFor("unknown", "unknown") == nil)}
Go Reference