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
+10.1k Golang : Compare files modify date example
+9k Golang : Populate or initialize struct with values example
+9k Golang : Inject/embed Javascript before sending out to browser example
+36.5k Golang : Save image to PNG, JPEG or GIF format.
+46.5k Golang : Marshal and unmarshal json.RawMessage struct example
+12.3k Golang : Display list of countries and ISO codes
+17.2k Golang : When to use init() function?
+14k Golang : Reverse IP address for reverse DNS lookup example
+30.8k Golang : Download file example
+16.6k Golang : Merge video(OpenCV) and audio(PortAudio) into a mp4 file
+9.3k Golang : How to get username from email address
+25.6k Golang : convert rune to integer value