Golang go/token.Token.IsKeyword function example
package go/token
IsKeyword returns true for tokens corresponding to keywords; it returns false otherwise.
Golang go/token.Token.IsKeyword function usage example
// getClass returns the CSS class name associated with tok.
func (h *Highlighter) getClass(tok token.Token) string {
switch {
case tok.IsKeyword(): // <--- here
return h.KeywordClass
case tok.IsLiteral():
if tok == token.IDENT {
return h.IdentClass
} else {
return h.LiteralClass
}
case tok.IsOperator():
return h.OperatorClass
case tok == token.COMMENT:
return h.CommentClass
case tok == token.ILLEGAL:
break
default:
panic(fmt.Sprintf("unknown token type: %v", tok))
}
return ""
}
References :
Advertisement
Something interesting
Tutorials
+11.7k Golang : Secure file deletion with wipe example
+29.5k Golang : Saving(serializing) and reading file with GOB
+19.2k Golang : Check if directory exist and create if does not exist
+7.7k Golang : Mapping Iban to Dunging alphabets
+23.1k Golang : simulate tail -f or read last line from log file example
+10.2k Golang : Find and replace data in all files recursively
+27.6k Golang : dial tcp: too many colons in address
+27.2k Golang : Find files by name - cross platform example
+13.6k Golang : Query string with space symbol %20 in between
+18.2k Golang : Get command line arguments
+37.5k Golang : Converting a negative number to positive number
+7.3k Golang : How to fix html/template : "somefile" is undefined error?