Golang go/token.Token.IsOperator function example
package go/token
IsOperator returns true for tokens corresponding to operators and delimiters; it returns false otherwise.
Golang go/token.Token.IsOperator 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
+8.3k Golang : Oanda bot with Telegram and RSI example
+26.8k Golang : Convert file content into array of bytes
+8.2k Golang : Routes multiplexer routing example with regular expression control
+16.3k Golang : How to extract links from web page ?
+12.2k Golang : calculate elapsed run time
+30k Golang : How to declare kilobyte, megabyte, gigabyte, terabyte and so on?
+6.5k Golang : Handling image beyond OpenCV video capture boundary
+30.9k Golang : Interpolating or substituting variables in string examples
+37.5k Upload multiple files with Go
+8.1k Golang : Get all countries phone codes
+13.2k Golang : Skip blank/empty lines in CSV file and trim whitespaces example
+4.3k Golang : Converting individual Jawi alphabet to Rumi(Romanized) alphabet example