Golang go/token.Token.String function examples

package go/token

String returns the string corresponding to the token tok. For operators, delimiters, and keywords the string is the actual token character sequence (e.g., for the token ADD, the string is "+"). For all other tokens the string corresponds to the token constant name (e.g. for the token IDENT, the string is "IDENT").

Golang go/token.Token.String function usage examples

Example 1:

 var e *ast.BinaryExpr
 var edges []Value
 phi := &Phi{Edges: edges, Comment: e.Op.String()}

Example 2:

 switch x := arg.(type) {
 ...
 case token.Token:
 s := x.String()

Reference :

http://golang.org/pkg/go/token/#Token.String

Advertisement