Standard library / go/token
go/token.Lookup()
Returns the keyword token or IDENT. It does not validate identifier spelling. Expected stdout: 'func IDENT IDENT\n'.
Formal Syntax & Structure
go syntaxgo
func Lookup(ident string) TokenParameters & Attributes
| Name | Type | Description |
|---|---|---|
| ident | string | Identifier spelling to look up. |
Return Value
Token
Returns the keyword token or IDENT.
Working Example
Example Snippetgo
package main
import ( "fmt" "go/token")
func main() { fmt.Println(token.Lookup("func"), token.Lookup("name"), token.Lookup("2x")) }