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.8k Golang : Heap sort example
+6.1k PageSpeed : Clear or flush cache on web server
+11.9k Golang : How to parse plain email text and process email header?
+26.4k Golang : Convert(cast) string to uint8 type and back to string
+5.3k Golang : Pad file extension automagically
+15.2k JavaScript/JQuery : Detect or intercept enter key pressed example
+12.7k Golang : Send data to /dev/null a.k.a blackhole with ioutil.Discard
+18.6k Golang : Generate thumbnails from images
+15.6k Golang : Force download file example
+6k Golang : Function as an argument type example
+21.8k Golang : Convert string slice to struct and access with reflect example
+7.9k Javascript : How to check a browser's Do Not Track status?