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
+32.4k Golang : Math pow(the power of x^y) example
+20.7k Android Studio : AlertDialog and EditText to get user string input example
+3.6k Java : Get FX sentiment from website example
+6.5k Elasticsearch : Shutdown a local node
+13.4k Golang : Generate Code128 barcode
+5.4k Unix/Linux : How to archive and compress entire directory ?
+4.7k Unix/Linux : How to pipe/save output of a command to file?
+13.3k Golang : Date and Time formatting
+4.9k Unix/Linux : secure copying between servers with SCP command examples
+19.4k Golang : Fix cannot download, $GOPATH not set error