Standard library / go/token
go/token.IsIdentifier()
Checks Go identifier spelling and rejects keywords. Predeclared identifiers are allowed. Expected stdout: 'true false false\n'.
Formal Syntax & Structure
go syntaxgo
func IsIdentifier(name string) boolParameters & Attributes
| Name | Type | Description |
|---|---|---|
| name | string | Identifier spelling to classify. |
Return Value
bool
Checks Go identifier spelling and rejects keywords.
Working Example
Example Snippetgo
package main
import ( "fmt" "go/token")
func main() { fmt.Println(token.IsIdentifier("π2"), token.IsIdentifier("2x"), token.IsIdentifier("func"))}