Golang go/token.Token.IsKeyword function example
package go/token
IsKeyword returns true for tokens corresponding to keywords; it returns false otherwise.
Golang go/token.Token.IsKeyword function usage example
// getClass returns the CSS class name associated with tok.
func (h *Highlighter) getClass(tok token.Token) string {
switch {
case tok.IsKeyword(): // <--- here
return h.KeywordClass
case tok.IsLiteral():
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
+5k Golang : micron to centimeter example
+52.6k Golang : How to get struct field and value by name
+20.3k Swift : Convert (cast) Int to int32 or Uint32
+5.6k Unix/Linux : How to find out the hard disk size?
+8.3k Golang : Check if integer is power of four example
+13.5k Golang : How to get year, month and day?
+33.7k Golang : All update packages with go get command
+7.8k Golang : Load DSA public key from file example
+20.7k Android Studio : AlertDialog and EditText to get user string input example
+10.6k Golang : ISO8601 Duration Parser example
+8.1k Golang : Variadic function arguments sanity check example
+6.6k Golang : How to validate ISBN?