asthelper

package
v0.0.0-...-3696fba Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 18, 2024 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssignDefineStmt

func AssignDefineStmt(Lhs ast.Expr, Rhs ast.Expr) *ast.AssignStmt

AssignDefineStmt "Lhs := Rhs"

func AssignStmt

func AssignStmt(Lhs ast.Expr, Rhs ast.Expr) *ast.AssignStmt

AssignStmt "Lhs = Rhs"

func BlockStmt

func BlockStmt(stmts ...ast.Stmt) *ast.BlockStmt

BlockStmt a block of multiple statements e.g. a function body

func CallExpr

func CallExpr(fun ast.Expr, args ...ast.Expr) *ast.CallExpr

CallExpr "fun(arg)"

func CallExprByName

func CallExprByName(fun string, args ...ast.Expr) *ast.CallExpr

CallExprByName "fun(args...)"

func ConstToAst

func ConstToAst(val constant.Value) ast.Expr

func DataToArray

func DataToArray(data []byte) *ast.CompositeLit

DataToArray turns a byte slice like []byte{1, 2, 3} into an AST expression

func DataToByteSlice

func DataToByteSlice(data []byte) *ast.CallExpr

DataToByteSlice turns a byte slice like []byte{1, 2, 3} into an AST expression

func ExprStmt

func ExprStmt(expr ast.Expr) *ast.ExprStmt

ExprStmt convert an ast.Expr to an ast.Stmt

func IndexExpr

func IndexExpr(name string, index ast.Expr) *ast.IndexExpr

IndexExpr "name[index]"

func IndexExprByExpr

func IndexExprByExpr(xExpr, indexExpr ast.Expr) *ast.IndexExpr

IndexExprByExpr "xExpr[indexExpr]"

func IntLit

func IntLit(value int) *ast.BasicLit

IntLit returns an ast.BasicLit of kind INT

func LambdaCall

func LambdaCall(resultType ast.Expr, block *ast.BlockStmt) *ast.CallExpr

LambdaCall "func() resultType {block}()"

func ReturnStmt

func ReturnStmt(results ...ast.Expr) *ast.ReturnStmt

ReturnStmt "return result"

func SelectExpr

func SelectExpr(x ast.Expr, sel *ast.Ident) *ast.SelectorExpr

SelectExpr "x.sel"

func StringLit

func StringLit(value string) *ast.BasicLit

StringLit returns an ast.BasicLit of kind STRING

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL