Standard library / go/token

go/token.Token.IsLiteral()

Reports whether the token represents an identifier or basic literal class. Expected stdout: 'true true false\n'.

Formal Syntax & Structure

go syntaxgo
func (tok Token) IsLiteral() bool

Return Value

bool

Reports whether the token represents an identifier or basic literal class.

Working Example

Example Snippetgo
package main
import (  "fmt"  "go/token")
func main() { fmt.Println(token.IDENT.IsLiteral(), token.INT.IsLiteral(), token.ADD.IsLiteral()) }
Go Reference