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
+19.1k Golang : Clearing slice
+17.1k Golang : XML to JSON example
+6k Golang : How to verify input is rune?
+16.3k Golang : Find out mime type from bytes in buffer
+10.6k Golang : ISO8601 Duration Parser example
+10.3k Golang : Embed secret text string into binary(executable) file
+16.7k Golang : Gzip file example
+25.8k Golang : Daemonizing a simple web server process example
+6.7k Golang : Reverse by word
+7.4k Golang : How to detect if a sentence ends with a punctuation?
+17.5k Golang : Find smallest number in array
+4.8k Golang : A program that contain another program and executes it during run-time