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
+5.6k Javascript : How to refresh page with JQuery ?
+33k Golang : How to check if a date is within certain range?
+5.4k Javascript : How to loop over and parse JSON data?
+5.4k Golang : Reclaim memory occupied by make() example
+5.3k Golang : Pad file extension automagically
+35.1k Golang : Upload and download file to/from AWS S3
+17k Golang : How to save log messages to file?
+9.4k Golang : How to protect your source code from client, hosting company or hacker?
+14.5k Golang : Overwrite previous output with count down timer
+7.5k Golang : Create zip/ePub file without compression(use Store algorithm)
+6.2k Golang : Process non-XML/JSON formatted ASCII text file example
+8.3k Golang: Prevent over writing file with md5 hash