Standard library / go/token
go/token.IsKeyword()
Checks whether a string is a reserved Go keyword. Expected stdout: 'true false\n'.
Formal Syntax & Structure
go syntaxgo
func IsKeyword(name string) boolParameters & Attributes
| Name | Type | Description |
|---|---|---|
| name | string | Identifier spelling to classify. |
Return Value
bool
Checks whether a string is a reserved Go keyword.
Working Example
Example Snippetgo
package main
import ( "fmt" "go/token")
func main() { fmt.Println(token.IsKeyword("return"), token.IsKeyword("len")) }