Standard library / go/types

go/types.TypeAndValue.HasOk()

Reports whether the expression can be used in a comma-ok assignment. Expected stdout: 'false\n'.

Formal Syntax & Structure

go syntaxgo
func (tv TypeAndValue) HasOk() bool

Return Value

bool

Reports whether the expression can be used in a comma-ok assignment.

Working Example

Example Snippetgo
package main
import (  "fmt"  "go/token"  "go/types")
func check(e error) {  if e != nil {    panic(e)  }}
func main() {  tv, e := types.Eval(token.NewFileSet(), nil, 0, "2+3")  check(e)  fmt.Println(tv.HasOk())}
Go Reference