Standard library / go/types

go/types.Struct.Underlying()

Returns the underlying type. An unnamed composite type is its own underlying type. Expected stdout: 'true\n'.

Formal Syntax & Structure

go syntaxgo
func (t *Struct) Underlying() Type

Return Value

Type

Returns the underlying type.

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.Underlying() == t)}
Go Reference