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
+17k Golang : Get input from keyboard
+7.5k Golang : Create zip/ePub file without compression(use Store algorithm)
+33.8k Golang : convert(cast) bytes to string
+5k Golang : micron to centimeter example
+4.7k MariaDB/MySQL : Form select statement or search query with Chinese characters
+16.6k Golang : Generate QR codes for Google Authenticator App and fix "Cannot interpret QR code" error
+19.2k Golang : Populate dropdown with html/template example
+14.2k Golang : Fix image: unknown format error
+12.3k Golang : Validate email address
+22.1k Golang : Match strings by wildcard patterns with filepath.Match() function
+4.7k Golang : How to pass data between controllers with JSON Web Token
+8.2k Golang : Add build version and other information in executables