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
+13.4k Golang : Increment string example
+13.5k Facebook PHP getUser() returns 0
+6.4k PHP : Proper way to get UTF-8 character or string length
+7.3k Golang : alternative to os.Exit() function
+8.6k Golang : Convert(cast) []byte to io.Reader type
+7.5k Golang : Detect sample rate, channels or latency with PortAudio
+9.9k Golang : Turn string or text file into slice example
+7.2k Golang : Dealing with postal or zip code example
+6.8k Golang : Find the longest line of text example
+16.1k Golang : Generate universally unique identifier(UUID) example
+7k Golang : constant 20013 overflows byte error message