Golang go/ast.BinaryExpr type examples
package go/ast
A BinaryExpr node represents a binary expression.
Golang go/ast.BinaryExpr type usage examples
Example 1:
func NodeDescription(n ast.Node) string {
switch n := n.(type) {
case *ast.ArrayType:
return "array type"
case *ast.AssignStmt:
return "assignment"
case *ast.BinaryExpr:
return fmt.Sprintf("binary %s operation", n.Op)
...
}
Example 2:
func isBinary(expr ast.Expr) bool {
_, ok := expr.(*ast.BinaryExpr)
return ok
}
Reference :
Advertisement
Something interesting
Tutorials
+8.2k Golang : Add build version and other information in executables
+17.2k Golang : When to use init() function?
+8.8k Android Studio : Image button and button example
+8.7k Golang : Combine slices but preserve order example
+8.3k Golang : Count leading or ending zeros(any item of interest) example
+7.3k Golang : Calculate how many weeks left to go in a given year
+8.6k Golang : Convert(cast) []byte to io.Reader type
+11.2k Golang : Calculate Relative Strength Index(RSI) example
+21.1k Golang : Get password from console input without echo or masked