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
+6k Linux/MacOSX : Search for files by filename and extension with find command
+12.4k Golang : Extract part of string with regular expression
+13.9k Golang : How to determine if a year is leap year?
+11.1k Golang : Read until certain character to break for loop
+10.1k Golang : Identifying Golang HTTP client request
+5.4k Golang : fmt.Println prints out empty data from struct
+14.8k Golang : Get URI segments by number and assign as variable example
+10.9k Golang : Sieve of Eratosthenes algorithm
+8.1k Golang : Variadic function arguments sanity check example
+18.5k Golang : Example for RSA package functions
+7.6k Golang : Convert(cast) io.Reader type to string
+12.7k Golang : Send data to /dev/null a.k.a blackhole with ioutil.Discard