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
+21.6k Golang : Encrypt and decrypt data with TripleDES
+16.4k Golang : Convert slice to array
+9.1k Golang : Handle sub domain with Gin
+25k Golang : Create PDF file from HTML file
+19.1k Golang : Clearing slice
+19.2k Golang : Delete item from slice based on index/key position
+6.7k Golang : Humanize and Titleize functions
+21.4k Curl usage examples with Golang
+12.6k Golang : Exit, terminating or aborting a program
+5k Golang : Get a list of crosses(instruments) available to trade from Oanda account
+6.9k Fix sudo yum hang problem with no output or error messages
+8.6k Android Studio : Import third-party library or package into Gradle Scripts