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
+15.8k Golang : Get digits from integer before and after given position example
+10.2k Golang : Use regular expression to get all upper case or lower case characters example
+18.2k Golang : Get command line arguments
+23.2k Golang : Print out struct values in string format
+10.6k Golang : Simple File Server
+7k Golang : Levenshtein distance example
+17.9k Golang : Qt image viewer example
+15.3k Golang : Get query string value on a POST request
+18k Golang : How to log each HTTP request to your web server?
+5.7k Linux/Unix/PHP : Restart PHP-FPM
+17k Golang : Fix cannot convert buffer (type *bytes.Buffer) to type string error
+9.9k Golang : ffmpeg with os/exec.Command() returns non-zero status