Golang go/token.Token.IsLiteral function example
package go/token
IsLiteral returns true for tokens corresponding to identifiers and basic type literals; it returns false otherwise.
Golang go/token.Token.IsLiteral function usage example
// getClass returns the CSS class name associated with tok.
func (h *Highlighter) getClass(tok token.Token) string {
switch {
case tok.IsKeyword():
return h.KeywordClass
case tok.IsLiteral(): // <---- here
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.2k Golang : Calculate Relative Strength Index(RSI) example
+10.8k Golang : Command line file upload program to server example
+13.9k Golang : Get current time
+14.6k Golang : Execute function at intervals or after some delay
+7.9k Golang : Get today's weekday name and calculate target day distance example
+9.1k Golang : Get curl -I or head data from URL example
+13.1k Golang : Handle or parse date string with Z suffix(RFC3339) example
+4k Detect if Google Analytics and Developer Media are loaded properly or not
+39.2k Golang : How to read CSV file
+33.6k Golang : How to check if slice or array is empty?
+6.8k Get Facebook friends working in same company