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
+22.5k Golang : Convert Unix timestamp to UTC timestamp
+33.6k Golang : How to check if slice or array is empty?
+5.9k Golang : Shuffle array of list
+16.3k Golang : How to extract links from web page ?
+10.1k Golang : Edge detection with Sobel method
+9.1k Golang : Handle sub domain with Gin
+8.1k Golang : Tell color name with OpenCV example
+9.9k Golang : Translate language with language package example
+25.2k Golang : Storing cookies in http.CookieJar example
+9.4k Golang : Qt Yes No and Quit message box example
+9k Golang : automatically figure out array length(size) with three dots