astcopy: github.com/go-toolsmith/astcopy Index | Examples | Files

package astcopy

import "github.com/go-toolsmith/astcopy"

Package astcopy implements Go AST reflection-free deep copy operations.

Code:

x := strparse.Expr(`1 + 2`).(*ast.BinaryExpr)
y := astcopy.BinaryExpr(x)
fmt.Println(astequal.Expr(x, y)) // => true

// Now modify x and make sure y is not modified.
z := astcopy.BinaryExpr(y)
x.Op = token.SUB
fmt.Println(astequal.Expr(y, z)) // => true
fmt.Println(astequal.Expr(x, y)) // => false

Output:

true
true
false

Index

Examples

Package Files

astcopy.go

func ArrayType Uses

func ArrayType(x *ast.ArrayType) *ast.ArrayType

ArrayType returns x deep copy. Copy of nil argument is nil.

func AssignStmt Uses

func AssignStmt(x *ast.AssignStmt) *ast.AssignStmt

AssignStmt returns x deep copy. Copy of nil argument is nil.

func BadDecl Uses

func BadDecl(x *ast.BadDecl) *ast.BadDecl

BadDecl returns x deep copy. Copy of nil argument is nil.

func BadExpr Uses

func BadExpr(x *ast.BadExpr) *ast.BadExpr

BadExpr returns x deep copy. Copy of nil argument is nil.

func BadStmt Uses

func BadStmt(x *ast.BadStmt) *ast.BadStmt

BadStmt returns x deep copy. Copy of nil argument is nil.

func BasicLit Uses

func BasicLit(x *ast.BasicLit) *ast.BasicLit

BasicLit returns x deep copy. Copy of nil argument is nil.

func BinaryExpr Uses

func BinaryExpr(x *ast.BinaryExpr) *ast.BinaryExpr

BinaryExpr returns x deep copy. Copy of nil argument is nil.

func BlockStmt Uses

func BlockStmt(x *ast.BlockStmt) *ast.BlockStmt

BlockStmt returns x deep copy. Copy of nil argument is nil.

func BranchStmt Uses

func BranchStmt(x *ast.BranchStmt) *ast.BranchStmt

BranchStmt returns x deep copy. Copy of nil argument is nil.

func CallExpr Uses

func CallExpr(x *ast.CallExpr) *ast.CallExpr

CallExpr returns x deep copy. Copy of nil argument is nil.

func CaseClause Uses

func CaseClause(x *ast.CaseClause) *ast.CaseClause

CaseClause returns x deep copy. Copy of nil argument is nil.

func ChanType Uses

func ChanType(x *ast.ChanType) *ast.ChanType

ChanType returns x deep copy. Copy of nil argument is nil.

func CommClause Uses

func CommClause(x *ast.CommClause) *ast.CommClause

CommClause returns x deep copy. Copy of nil argument is nil.

func Comment Uses

func Comment(x *ast.Comment) *ast.Comment

Comment returns x deep copy. Copy of nil argument is nil.

func CommentGroup Uses

func CommentGroup(x *ast.CommentGroup) *ast.CommentGroup

CommentGroup returns x deep copy. Copy of nil argument is nil.

func CompositeLit Uses

func CompositeLit(x *ast.CompositeLit) *ast.CompositeLit

CompositeLit returns x deep copy. Copy of nil argument is nil.

func Decl Uses

func Decl(x ast.Decl) ast.Decl

Decl returns x declaration deep copy. Copy of nil argument is nil.

func DeclList Uses

func DeclList(xs []ast.Decl) []ast.Decl

DeclList returns xs declaration slice deep copy. Copy of nil argument is nil.

func DeclStmt Uses

func DeclStmt(x *ast.DeclStmt) *ast.DeclStmt

DeclStmt returns x deep copy. Copy of nil argument is nil.

func DeferStmt Uses

func DeferStmt(x *ast.DeferStmt) *ast.DeferStmt

DeferStmt returns x deep copy. Copy of nil argument is nil.

func Ellipsis Uses

func Ellipsis(x *ast.Ellipsis) *ast.Ellipsis

Ellipsis returns x deep copy. Copy of nil argument is nil.

func EmptyStmt Uses

func EmptyStmt(x *ast.EmptyStmt) *ast.EmptyStmt

EmptyStmt returns x deep copy. Copy of nil argument is nil.

func Expr Uses

func Expr(x ast.Expr) ast.Expr

Expr returns x expression deep copy. Copy of nil argument is nil.

func ExprList Uses

func ExprList(xs []ast.Expr) []ast.Expr

ExprList returns xs expression slice deep copy. Copy of nil argument is nil.

func ExprStmt Uses

func ExprStmt(x *ast.ExprStmt) *ast.ExprStmt

ExprStmt returns x deep copy. Copy of nil argument is nil.

func Field Uses

func Field(x *ast.Field) *ast.Field

Field returns x deep copy. Copy of nil argument is nil.

func FieldList Uses

func FieldList(x *ast.FieldList) *ast.FieldList

FieldList returns x deep copy. Copy of nil argument is nil.

func File Uses

func File(x *ast.File) *ast.File

File returns x deep copy. Copy of nil argument is nil.

func ForStmt Uses

func ForStmt(x *ast.ForStmt) *ast.ForStmt

ForStmt returns x deep copy. Copy of nil argument is nil.

func FuncDecl Uses

func FuncDecl(x *ast.FuncDecl) *ast.FuncDecl

FuncDecl returns x deep copy. Copy of nil argument is nil.

func FuncLit Uses

func FuncLit(x *ast.FuncLit) *ast.FuncLit

FuncLit returns x deep copy. Copy of nil argument is nil.

func FuncType Uses

func FuncType(x *ast.FuncType) *ast.FuncType

FuncType returns x deep copy. Copy of nil argument is nil.

func GenDecl Uses

func GenDecl(x *ast.GenDecl) *ast.GenDecl

GenDecl returns x deep copy. Copy of nil argument is nil.

func GoStmt Uses

func GoStmt(x *ast.GoStmt) *ast.GoStmt

GoStmt returns x deep copy. Copy of nil argument is nil.

func Ident Uses

func Ident(x *ast.Ident) *ast.Ident

Ident returns x deep copy. Copy of nil argument is nil.

func IdentList Uses

func IdentList(xs []*ast.Ident) []*ast.Ident

IdentList returns xs identifier slice deep copy. Copy of nil argument is nil.

func IfStmt Uses

func IfStmt(x *ast.IfStmt) *ast.IfStmt

IfStmt returns x deep copy. Copy of nil argument is nil.

func ImportSpec Uses

func ImportSpec(x *ast.ImportSpec) *ast.ImportSpec

ImportSpec returns x deep copy. Copy of nil argument is nil.

func IncDecStmt Uses

func IncDecStmt(x *ast.IncDecStmt) *ast.IncDecStmt

IncDecStmt returns x deep copy. Copy of nil argument is nil.

func IndexExpr Uses

func IndexExpr(x *ast.IndexExpr) *ast.IndexExpr

IndexExpr returns x deep copy. Copy of nil argument is nil.

func InterfaceType Uses

func InterfaceType(x *ast.InterfaceType) *ast.InterfaceType

InterfaceType returns x deep copy. Copy of nil argument is nil.

func KeyValueExpr Uses

func KeyValueExpr(x *ast.KeyValueExpr) *ast.KeyValueExpr

KeyValueExpr returns x deep copy. Copy of nil argument is nil.

func LabeledStmt Uses

func LabeledStmt(x *ast.LabeledStmt) *ast.LabeledStmt

LabeledStmt returns x deep copy. Copy of nil argument is nil.

func MapType Uses

func MapType(x *ast.MapType) *ast.MapType

MapType returns x deep copy. Copy of nil argument is nil.

func Node Uses

func Node(x ast.Node) ast.Node

Node returns x node deep copy. Copy of nil argument is nil.

func NodeList Uses

func NodeList(xs []ast.Node) []ast.Node

NodeList returns xs node slice deep copy. Copy of nil argument is nil.

func Package Uses

func Package(x *ast.Package) *ast.Package

Package returns x deep copy. Copy of nil argument is nil.

func ParenExpr Uses

func ParenExpr(x *ast.ParenExpr) *ast.ParenExpr

ParenExpr returns x deep copy. Copy of nil argument is nil.

func RangeStmt Uses

func RangeStmt(x *ast.RangeStmt) *ast.RangeStmt

RangeStmt returns x deep copy. Copy of nil argument is nil.

func ReturnStmt Uses

func ReturnStmt(x *ast.ReturnStmt) *ast.ReturnStmt

ReturnStmt returns x deep copy. Copy of nil argument is nil.

func SelectStmt Uses

func SelectStmt(x *ast.SelectStmt) *ast.SelectStmt

SelectStmt returns x deep copy. Copy of nil argument is nil.

func SelectorExpr Uses

func SelectorExpr(x *ast.SelectorExpr) *ast.SelectorExpr

SelectorExpr returns x deep copy. Copy of nil argument is nil.

func SendStmt Uses

func SendStmt(x *ast.SendStmt) *ast.SendStmt

SendStmt returns x deep copy. Copy of nil argument is nil.

func SliceExpr Uses

func SliceExpr(x *ast.SliceExpr) *ast.SliceExpr

SliceExpr returns x deep copy. Copy of nil argument is nil.

func Spec Uses

func Spec(x ast.Spec) ast.Spec

Spec returns x deep copy. Copy of nil argument is nil.

func SpecList Uses

func SpecList(xs []ast.Spec) []ast.Spec

SpecList returns xs spec slice deep copy. Copy of nil argument is nil.

func StarExpr Uses

func StarExpr(x *ast.StarExpr) *ast.StarExpr

StarExpr returns x deep copy. Copy of nil argument is nil.

func Stmt Uses

func Stmt(x ast.Stmt) ast.Stmt

Stmt returns x statement deep copy. Copy of nil argument is nil.

func StmtList Uses

func StmtList(xs []ast.Stmt) []ast.Stmt

StmtList returns xs statement slice deep copy. Copy of nil argument is nil.

func StructType Uses

func StructType(x *ast.StructType) *ast.StructType

StructType returns x deep copy. Copy of nil argument is nil.

func SwitchStmt Uses

func SwitchStmt(x *ast.SwitchStmt) *ast.SwitchStmt

SwitchStmt returns x deep copy. Copy of nil argument is nil.

func TypeAssertExpr Uses

func TypeAssertExpr(x *ast.TypeAssertExpr) *ast.TypeAssertExpr

TypeAssertExpr returns x deep copy. Copy of nil argument is nil.

func TypeSpec Uses

func TypeSpec(x *ast.TypeSpec) *ast.TypeSpec

TypeSpec returns x deep copy. Copy of nil argument is nil.

func TypeSwitchStmt Uses

func TypeSwitchStmt(x *ast.TypeSwitchStmt) *ast.TypeSwitchStmt

TypeSwitchStmt returns x deep copy. Copy of nil argument is nil.

func UnaryExpr Uses

func UnaryExpr(x *ast.UnaryExpr) *ast.UnaryExpr

UnaryExpr returns x deep copy. Copy of nil argument is nil.

func ValueSpec Uses

func ValueSpec(x *ast.ValueSpec) *ast.ValueSpec

ValueSpec returns x deep copy. Copy of nil argument is nil.

Package astcopy imports 1 packages (graph) and is imported by 1 packages. Updated 2018-07-14. Refresh now. Tools for package owners.