Standard library / go/types

go/types.Struct

Represents a Go struct type in the semantic model, not a runtime value. Expected stdout: 'struct{X int "json:x"}\n'.

Formal Syntax & Structure

go syntaxgo
type Struct struct {}

Working Example

Example Snippetgo
package main
import (  "fmt"  "go/types")
func main() {  t := types.NewStruct([]*types.Var{types.NewField(0, nil, "X", types.Typ[types.Int], false)}, []string{"json:x"})  fmt.Println(t)}
Go Reference