Standard library / go/types

go/types.Union.Underlying()

Returns the union itself. Expected stdout: 'true\n'.

Formal Syntax & Structure

go syntaxgo
func (u *Union) Underlying() Type

Return Value

Type

Returns the union itself.

Working Example

Example Snippetgo
package main
import (  "fmt"  "go/types")
func union() *types.Union {  return types.NewUnion([]*types.Term{term(), types.NewTerm(false, types.Typ[types.String])})}
func term() *types.Term { return types.NewTerm(true, types.Typ[types.Int]) }
func main() { v := union(); fmt.Println(v.Underlying() == v) }
Go Reference