astbuilder

package
v0.0.0-...-99be886 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultCommentWrapWidth = 120

Variables

This section is empty.

Functions

func AddComment

func AddComment(commentList *dst.Decorations, comment string)

AddComment adds a single comment line to the specified list

func AddComments

func AddComments(commentList *dst.Decorations, comments []string)

AddComments adds preformatted comments to the specified list

func AddUnwrappedComment

func AddUnwrappedComment(commentList *dst.Decorations, comment string)

AddUnwrappedComment adds a single comment to the specified list. The text is not wrapped. Respects any existing line breaks specified by \n or <br>.

func AddUnwrappedComments

func AddUnwrappedComments(commentList *dst.Decorations, comments []string)

AddUnwrappedComments adds comments to the specified list. The text is not wrapped. Respects any existing line breaks specified by \n or <br>

func AddWrappedComment

func AddWrappedComment(commentList *dst.Decorations, comment string)

AddWrappedComment adds a single comment to the specified list, wrapping text as it goes. Respects any existing line breaks specified by \n or <br>

func AddWrappedCommentAtWidth

func AddWrappedCommentAtWidth(commentList *dst.Decorations, comment string, width int)

AddWrappedCommentAtWidth adds a single comment to the specified list, wrapping text to the specified width as it goes. Respects any existing line breaks specified by \n or <br>

func AddWrappedComments

func AddWrappedComments(commentList *dst.Decorations, comments []string)

AddWrappedComments adds comments to the specified list, wrapping text to the specified width as it goes. Respects any existing line breaks specified by \n or <br>

func AddrOf

func AddrOf(expr dst.Expr) *dst.UnaryExpr

AddrOf returns a statement that gets the address of the provided expression.

&<expr>

func AppendItemToSlice

func AppendItemToSlice(lhs dst.Expr, rhs dst.Expr) dst.Stmt

AppendItemToSlice returns a statement to append a single item to a slice

<lhs> = append(<lhs>, <rhs>)

func AppendItemsToSlice

func AppendItemsToSlice(lhs dst.Expr, rhs ...dst.Expr) dst.Stmt

AppendItemsToSlice returns a statement to append many individual items to a slice

<lhs> = append(<lhs>, <rhs>, <rhs>, <rhs>, ...)

func AppendSliceToSlice

func AppendSliceToSlice(lhs dst.Expr, rhs dst.Expr) dst.Stmt

AppendSliceToSlice returns a statement to append a slice to another slice

<lhs> = append(<lhs>, <rhs>...)

func AreEqual

func AreEqual(lhs dst.Expr, rhs dst.Expr) *dst.BinaryExpr

AreEqual generates a == comparison between the two expressions

<lhs> == <rhs>

func AreNotEqual

func AreNotEqual(lhs dst.Expr, rhs dst.Expr) *dst.BinaryExpr

AreNotEqual generates a != comparison between the two expressions

<lhs> != <rhs>

func AsReference

func AsReference(expr dst.Expr) dst.Expr

AsReference returns a statement that is a reference to the supplied expression

&<expr>

If the expression given is a StarExpr dereference, we unwrap it instead of taking its address

func AssignToInterface

func AssignToInterface(lhsVar string, rhs dst.Expr) dst.Decl

AssignToInterface performs an assignment of a well-typed variable to an interface{}. This is usually used to perform a type assertion on a concrete type in a subsequent statement (which Go doesn't allow, it only allows type assertions on interface types).

var <lhsVar> interface{} = <rhs>

func AssignmentStatement

func AssignmentStatement(lhs dst.Expr, tok token.Token, rhs dst.Expr) *dst.AssignStmt

AssignmentStatement allows for either variable declaration or assignment by passing the required token Only token.DEFINE and token.ASSIGN are supported, other values will panic. Use SimpleAssignment or ShortDeclaration if possible; use this method only if you must.

func BinaryExpr

func BinaryExpr(lhs dst.Expr, op token.Token, rhs dst.Expr) *dst.BinaryExpr

func CallExpr

func CallExpr(expr dst.Expr, funcName string, arguments ...dst.Expr) *dst.CallExpr

CallExpr creates an expression to call the named function with the specified arguments

<expr>.<funcName>(arguments...)

func CallExprAsStmt

func CallExprAsStmt(expr dst.Expr, funcName string, arguments ...dst.Expr) dst.Stmt

CallExprAsStmt creates a statement to invoke the named function with the specified arguments

<expr>.<funcName>(arguments...)

If you want to use the result of the function call as a value, use CallExpr() instead

func CallFunc

func CallFunc(funcName string, arguments ...dst.Expr) *dst.CallExpr

CallFunc creates an expression to call a function with specified arguments

<funcName>(<arguments>...)

func CallFuncAsStmt

func CallFuncAsStmt(funcName string, arguments ...dst.Expr) dst.Stmt

CallFuncAsStmt creates a statement to invoke a function with specified arguments

<funcName>(arguments...)

If you want to use the result of the function call as a value, use CallFunc() instead

func CallQualifiedFunc

func CallQualifiedFunc(qualifier string, funcName string, arguments ...dst.Expr) *dst.CallExpr

CallQualifiedFunc creates an expression to call a qualified function with the specified arguments

<qualifier>.<funcName>(arguments...)

func CallQualifiedFuncAsStmt

func CallQualifiedFuncAsStmt(qualifier string, funcName string, arguments ...dst.Expr) dst.Stmt

CallQualifiedFuncAsStmt creates a statement to invoke a qualified function with specified arguments

<qualifier>.<funcName>(arguments...)

If you want to use the result of the function call as a value, use CallQualifiedFunc() instead

func CheckErrorAndReturn

func CheckErrorAndReturn(otherReturns ...dst.Expr) dst.Stmt

CheckErrorAndReturn checks if the err is non-nil, and if it is returns.

if err != nil {
	return <otherReturns...>, err
}

func CheckErrorAndSingleStatement

func CheckErrorAndSingleStatement(stmt dst.Stmt) dst.Stmt

CheckErrorAndSingleStatement checks if the err is non-nil, and if it is executes the provided statement.

if err != nil {
	<stmt>
}

func CheckErrorAndWrap

func CheckErrorAndWrap(errorsPackage string, message string, args ...dst.Expr) dst.Stmt

CheckErrorAndWrap checks if the err is non-nil, and if it is returns it, wrapped with additional information If no arguments are provided, will generate

if err != nil {
     return errors.Wrap(err, <message>)
}

otherwise will generate

if err != nil {
     return errors.Wrapf(err, <message>, <args>)
}

func CommentLength

func CommentLength(comments dst.Decorations) int

CommentLength returns the text length of the comments, including EoLN characters

func Continue

func Continue() dst.Stmt

Continue returns the continue keyword

func Declarations

func Declarations(declarations ...any) []dst.Decl

Declarations constructs a slice of dst.Decl by combining the given declarations. Pass any combination of dst.Decl and []dst.Decl as arguments; anything else will result in a runtime panic.

func Dereference

func Dereference(expr dst.Expr) dst.Expr

Dereference returns a statement that dereferences the pointer returned by the provided expression

*<expr>

func Expressions

func Expressions(expressions ...interface{}) []dst.Expr

Expression creates a slice of dst.Expr by combining the given expressions. Pass any combination of dst.Expr and []dst.Expr as arguments; anything else will result in a runtime panic.

func FormatError

func FormatError(fmtPackage string, formatString string, args ...dst.Expr) dst.Expr

FormatError produces a call to fmt.Errorf with the given format string and args

fmt.Errorf(<formatString>, <args>)

func IfEqual

func IfEqual(left dst.Expr, right dst.Expr, statements ...dst.Stmt) *dst.IfStmt

IfEqual executes a series of statements if the supplied expressions are

if <left> == <right> {
    <statements>
}

func IfExprOk

func IfExprOk(
	varName string,
	okName string,
	expr dst.Expr,
	statements ...dst.Stmt,
) *dst.IfStmt

IfExprOk evaluates an expression returning two values and executes the provided statements if the second value is true varName is the name of the variable to assign the first value to; okName is the name of the variable to assign the second value to; expr is the expression to evaluate; statements form the body of the if statement

func IfNil

func IfNil(toCheck dst.Expr, statements ...dst.Stmt) *dst.IfStmt

IfNil executes a series of statements if the supplied expression is nil

if <source> != nil {
    <statements>
}

func IfNotNil

func IfNotNil(toCheck dst.Expr, statements ...dst.Stmt) *dst.IfStmt

IfNotNil executes a series of statements if the supplied expression is not nil

if <source> != nil {
    <statements>
}

func IfNotOk

func IfNotOk(statements ...dst.Stmt) *dst.IfStmt

IfNotOk checks a boolean ok variable and if it is not ok runs the given statements

if !ok {
	<statements>
}

func IfOk

func IfOk(statements ...dst.Stmt) *dst.IfStmt

IfOk checks a boolean ok variable and if it is ok runs the given statements

if ok {
	<statements>
}

func IfType

func IfType(expr dst.Expr, typeExpr dst.Expr, local string, statements ...dst.Stmt) *dst.IfStmt

IfType does a type assertion and executes the provided statements if it is true expr is the expression to cast; typeExpr is the type we want to cast to; local is the name of the local variable to initialize statements form the body of the if statement

if <local>, ok := <expr>.(<typeExpr>); ok {
    <statements>
}

func InsertMap

func InsertMap(mapExpr dst.Expr, key dst.Expr, rhs dst.Expr) *dst.AssignStmt

InsertMap returns an assignment statement for inserting an item into a map

<mapExpr>[<key>] = <rhs>

func IntLiteral

func IntLiteral(value int) *dst.BasicLit

IntLiteral create the AST node for a literal integer value

func IterateOverMapWithKey

func IterateOverMapWithKey(key string, mapExpr dst.Expr, statements ...dst.Stmt) *dst.RangeStmt

IterateOverMapWithKey creates a statement to iterate over the content of a map using the specified identifiers for each key and value found.

for <key> := range <mapExpr> {
    <statements>
}

func IterateOverMapWithValue

func IterateOverMapWithValue(key string, item string, mapExpr dst.Expr, statements ...dst.Stmt) *dst.RangeStmt

IterateOverMapWithValue creates a statement to iterate over the content of a map using the specified identifiers for each key and value found.

for <key>, <item> := range <mapExpr> {
    <statements>
}

func IterateOverSlice

func IterateOverSlice(item string, list dst.Expr, statements ...dst.Stmt) *dst.RangeStmt

IterateOverSlice creates a statement to iterate over the content of a list using the specified identifier for each element in the list

for _, <item> := range <list> {
    <statements>
}

func IterateOverSliceWithIndex

func IterateOverSliceWithIndex(index string, item string, list dst.Expr, statements ...dst.Stmt) *dst.RangeStmt

IterateOverSliceWithIndex creates a statement to iterate over the content of a list using the specified identifiers for each index and element in the list

for <index>, <item> := range <list> {
    <statements>
}

func JoinAnd

func JoinAnd(exprs ...dst.Expr) dst.Expr

JoinAnd combines a sequence of expressiosn with the AND (&&) operator

func JoinBinaryOp

func JoinBinaryOp(op token.Token, spaceType dst.SpaceType, exprs ...dst.Expr) dst.Expr

JoinBinaryOp combines a sequence of expressions using a given operator op defines the operator to use to combine two adjacent expressions. spaceType specifies what kind of whitespace is needed after each one. exprs is the sequence of expressions to combine.

func JoinOr

func JoinOr(exprs ...dst.Expr) dst.Expr

JoinOr combines a sequence of expressions with the OR (||) operator If there are more than two expressions to combine, they're broken out on separate lines

func LocalVariableDeclaration

func LocalVariableDeclaration(ident string, typ dst.Expr, comment string) *dst.DeclStmt

LocalVariableDeclaration performs a local variable declaration for use within a method

var <ident> <typ>

func MakeEmptySlice

func MakeEmptySlice(listType dst.Expr, capacity dst.Expr) *dst.CallExpr

MakeEmptySlice returns the call expression for making a slice with a specified length that can be appended to using append(...)

make([]<value>, 0, <len>)

func MakeMap

func MakeMap(key dst.Expr, value dst.Expr) *dst.CallExpr

MakeMap returns the call expression for making a map

make(map[<key>]<value>)

func MakeMapWithCapacity

func MakeMapWithCapacity(key dst.Expr, value dst.Expr, capacity dst.Expr) *dst.CallExpr

MakeMapWithCapacity returns the call expression for making a map with a predefined capacity

make(map[<key>]<value>, <capacity>)

func MakeSlice

func MakeSlice(listType dst.Expr, capacity dst.Expr) *dst.CallExpr

MakeSlice returns the call expression for making a slice with a specified length

make([]<value>, <capacity>)

func NewVariable

func NewVariable(varName string, structName string) dst.Stmt

NewVariable creates a new declaration statement where a variable is declared with its default value.

For example:

var <varName> <structName>

Note that it does *not* do:

<varName> := <structName>{}

…as that does not work for enum types.

func NewVariableAssignment

func NewVariableAssignment(varName string, value dst.Expr) dst.Decl

NewVariableAssignmentWithType creates a new statement where a variable is declared with an implicit type. var <varName> <varType> = <varValue>

func NewVariableAssignmentWithType

func NewVariableAssignmentWithType(varName string, varType dst.Expr, value dst.Expr) dst.Decl

NewVariableAssignmentWithType creates a new statement where a variable is declared with an explicit type. var <varName> <varType> = <varValue>

func NewVariableQualified

func NewVariableQualified(varName string, qualifier string, structName string) dst.Stmt

NewVariableQualified creates a new declaration statement where a variable is declared with its default value.

For example:

var <varName> <packageRef>.<structName>

Note that it does *not* do:

<varName> := <packageRef>.<structName>{}

…as that does not work for enum types.

func NewVariableWithType

func NewVariableWithType(varName string, varType dst.Expr) dst.Stmt

func Nil

func Nil() *dst.Ident

Nil returns the nil identifier (not keyword!)

func NotEmpty

func NotEmpty(x dst.Expr) *dst.BinaryExpr

NotEmpty generates an `len(x) > 0` condition

func NotExpr

func NotExpr(expr dst.Expr) *dst.UnaryExpr

NotExpr generates a `!x` expression

func NotNil

func NotNil(x dst.Expr) *dst.BinaryExpr

NotNil generates an `x != nil` condition

func PointerTo

func PointerTo(expr dst.Expr) dst.Expr

PointerTo returns a statement that dereferences the pointer returned by the provided expression

*<expr>

Yes, this is identical to Dereference, but having both makes the code more readable

func QualifiedAssignment

func QualifiedAssignment(lhs dst.Expr, lhsSel string, tok token.Token, rhs dst.Expr) *dst.AssignStmt

QualifiedAssignment performs a simple assignment like:

<lhs>.<lhsSel> := <rhs>       // tok = token.DEFINE

or <lhs>.<lhsSel> = <rhs> // tok = token.ASSIGN

func QualifiedTypeName

func QualifiedTypeName(pkg string, name string) *dst.SelectorExpr

QualifiedTypeName generates a reference to a type within an imported package

<pkg>.<name>

func Reduce

func Reduce(operator func(l, r dst.Expr) dst.Expr, spaceType dst.SpaceType, exprs ...dst.Expr) dst.Expr

Reduce combines a sequence of expressions using the provided function. operator defines how to combine two adjacent expressions. spaceType specifies what kind of whitespace is needed after each one. exprs is the sequence of expressions to combine.

func ReturnIfExpr

func ReturnIfExpr(cond dst.Expr, returns ...dst.Expr) *dst.IfStmt

ReturnIfExpr returns if the expression evaluates as true

if <cond> {
	return <returns...>
}

func ReturnIfNil

func ReturnIfNil(toCheck dst.Expr, returns ...dst.Expr) dst.Stmt

ReturnIfNil checks if a variable is nil and if it is returns

if <toCheck> == nil {
	return <returns...>
}

func ReturnIfNotNil

func ReturnIfNotNil(toCheck dst.Expr, returns ...dst.Expr) dst.Stmt

ReturnIfNotNil checks if a variable is not nil and if it is returns

if <toCheck> != nil {
	return <returns...>
}

func ReturnIfNotOk

func ReturnIfNotOk(returns ...dst.Expr) *dst.IfStmt

ReturnIfNotOk checks a boolean ok variable and if it is not ok returns the specified values

if !ok {
	return <returns>
}

func ReturnIfOk

func ReturnIfOk(returns ...dst.Expr) *dst.IfStmt

ReturnIfOk checks a boolean ok variable and if it is ok returns the specified values

if ok {
	return <returns>
}

func ReturnNoError

func ReturnNoError() dst.Stmt

ReturnNoError creates a return nil statement for when no error occurs

// No error
return nil

func Returns

func Returns(returns ...dst.Expr) dst.Stmt

Returns creates a return statement with one or more expressions, of the form

return <expr>

or return <expr>, <expr>, ...

func Selector

func Selector(expr dst.Expr, names ...string) *dst.SelectorExpr

Selector generates a field reference into an existing expression

<expr>.<name0>.(<name1>.<name2>…)

func ShortDeclaration

func ShortDeclaration(id string, rhs dst.Expr) *dst.AssignStmt

ShortDeclaration performs a simple assignment like:

<id> := <rhs>

Method naming inspired by https://tour.golang.org/basics/10

func SimpleAssignment

func SimpleAssignment(lhs dst.Expr, rhs dst.Expr) *dst.AssignStmt

SimpleAssignment performs a simple assignment like:

<lhs> = <rhs>

See also ShortDeclaration

func SimpleAssignmentWithErr

func SimpleAssignmentWithErr(lhs dst.Expr, tok token.Token, rhs dst.Expr) *dst.AssignStmt

SimpleAssignmentWithErr performs a simple assignment like:

    <lhs>, err := <rhs>       // tok = token.DEFINE
or  <lhs>, err = <rhs>        // tok = token.ASSIGN

func SimpleIf

func SimpleIf(condition dst.Expr, statements ...dst.Stmt) *dst.IfStmt

SimpleIf creates a simple if statement with multiple statements

if <condition> {
    <trueBranch>
}

func SimpleIfElse

func SimpleIfElse(condition dst.Expr, trueBranch []dst.Stmt, falseBranch []dst.Stmt) *dst.IfStmt

SimpleIfElse creates a simple if else statement. Each branch may contain multiple statements.

if <condition> {
    <trueBranch>
} else {

    <falseBranch>
}

func SliceLiteral

func SliceLiteral(arrayType dst.Expr, items ...dst.Expr) dst.Expr

SliceLiteral creates a slice literal

[]<arrayType>{<items...>}

func StatementBlock

func StatementBlock(statements ...dst.Stmt) *dst.BlockStmt

StatementBlock generates a block containing the supplied statements If we're given a single statement that's already a block, we won't double wrap it

func Statements

func Statements(statements ...any) []dst.Stmt

Statements creates a slice of dst.Stmt by combining the given statements. Pass any combination of dst.Stmt and []dst.Stmt as arguments; anything else will result in a runtime panic.

func StringLiteral

func StringLiteral(content string) *dst.BasicLit

StringLiteral creates the AST node for a literal string value Leading and trailing quotes are added as required and any existing quotes are escaped

func StringLiteralf

func StringLiteralf(format string, a ...interface{}) *dst.BasicLit

StringLiteralf creates the AST node for a literal string value based on a format string Leading and trailing quotes are added as required and any existing quotes are escaped

func TextLiteral

func TextLiteral(content string) *dst.BasicLit

TextLiteral creates the AST node for a literal text value No additional text is included

func TextLiteralf

func TextLiteralf(format string, a ...interface{}) *dst.BasicLit

TextLiteralf creates the AST node for literal text based on a format string

func TypeAssert

func TypeAssert(lhs dst.Expr, rhs dst.Expr, typ dst.Expr) *dst.AssignStmt

TypeAssert returns an assignment statement with a type assertion

<lhs>, ok := <rhs>.(<type>)

func VariableDeclaration

func VariableDeclaration(ident string, typ dst.Expr, comment string) *dst.GenDecl

VariableDeclaration performs a global variable declaration

 // <comment>
	var <ident> <typ>

For a LocalVariable within a method, use LocalVariableDeclaration() to create an ast.Stmt instead

func WordWrap

func WordWrap(text string, width int) []string

WordWrap applies word wrapping to the specified string, returning a slice containing the lines.

func WrapError

func WrapError(errorsPackage string, err string, message string, args ...dst.Expr) dst.Expr

WrapError wraps the specified err. If no arguments are provided, will generate

errors.Wrap(err, <message>)

otherwise will generate

errors.Wrapf(err, <message>, <args>)

func WrappedError

func WrappedError(errorsPackage string, str string) dst.Expr

WrappedError returns the err local, wrapped with additional information

errors.Wrap(err, <message>)

(actual package name will be used, which will usually be 'errors')

func WrappedErrorf

func WrappedErrorf(errorsPackage string, template string, args ...interface{}) dst.Expr

WrappedErrorf returns the err local, wrapped with additional information

errors.Wrap(err, <message>)

(actual package name will be used, which will usually be 'errors')

Types

type CompositeLiteralBuilder

type CompositeLiteralBuilder struct {
	// contains filtered or unexported fields
}

CompositeLiteralBuilder captures the information required to generate code for an inline struct initialization

func NewCompositeLiteralBuilder

func NewCompositeLiteralBuilder(structType dst.Expr) *CompositeLiteralBuilder

NewCompositeLiteralBuilder creates a new instance for initialization of the specified struct structType is an expression to handle both structs from the current package and imported ones requiring qualification

func (*CompositeLiteralBuilder) AddField

AddField adds initialization of another field Returns the receiver to allow method chaining when desired

func (*CompositeLiteralBuilder) Build

Build constructs the actual dst.CompositeLit that's required

func (*CompositeLiteralBuilder) WithoutNewLines

func (b *CompositeLiteralBuilder) WithoutNewLines() *CompositeLiteralBuilder

WithoutNewLines returns the CompositeLiteralBuilder without NewLines enabled

type FuncDetails

type FuncDetails struct {
	ReceiverIdent string
	ReceiverType  dst.Expr
	Name          string
	Comments      []string
	Params        []*dst.Field
	Returns       []*dst.Field
	Body          []dst.Stmt
}

func NewTestFuncDetails

func NewTestFuncDetails(testingPackage string, testName string, body ...dst.Stmt) *FuncDetails

NewTestFuncDetails returns a FuncDetails for a test method Tests require a particular signature, so this makes it simpler to create test functions

func (*FuncDetails) AddComments

func (fn *FuncDetails) AddComments(comment ...string)

AddComments adds multiple comments to the function declaration

func (*FuncDetails) AddParameter

func (fn *FuncDetails) AddParameter(id string, parameterType dst.Expr)

AddParameter adds another parameter to the function definition

func (*FuncDetails) AddReturn

func (fn *FuncDetails) AddReturn(expr dst.Expr)

AddReturn adds a single return value to the function definition

func (*FuncDetails) AddReturns

func (fn *FuncDetails) AddReturns(types ...string)

AddReturns adds (possibly many) return values to the function definition

func (*FuncDetails) AddStatements

func (fn *FuncDetails) AddStatements(statements ...dst.Stmt)

AddStatements adds additional statements to the function

func (*FuncDetails) DefineFunc

func (fn *FuncDetails) DefineFunc() *dst.FuncDecl

DefineFunc defines a function (header, body, etc), like:

<comment>
func (<receiverIdent> <receiverType>) <name>(<params...>) (<returns...>) {
	<body...>
}

func (*FuncDetails) DefineFuncHeader

func (fn *FuncDetails) DefineFuncHeader() *dst.FuncDecl

DefineFuncHeader defines a function header like:

<comment>
func (<receiverIdent> <receiverType>) <name>(<params...>) (<returns...>)

type MapLiteral

type MapLiteral struct {
	// contains filtered or unexported fields
}

func NewMapLiteral

func NewMapLiteral(key dst.Expr, value dst.Expr) *MapLiteral

func (*MapLiteral) Add

func (m *MapLiteral) Add(key dst.Expr, value dst.Expr)

func (*MapLiteral) AsExpr

func (m *MapLiteral) AsExpr() dst.Expr

type SliceLiteralBuilder

type SliceLiteralBuilder struct {
	// contains filtered or unexported fields
}

SliceLiteralBuilder captures the information required to generate code for an inline slice initialization

func NewSliceLiteralBuilder

func NewSliceLiteralBuilder(sliceType dst.Expr, linePerElement bool) *SliceLiteralBuilder

NewSliceLiteralBuilder creates a new instance for initialization of the specified slice The linePerElt parameter determines if the slice literal should have a single element per line

func (*SliceLiteralBuilder) AddElement

func (b *SliceLiteralBuilder) AddElement(element dst.Expr) *SliceLiteralBuilder

AddElement adds an element to the slice literal Returns the receiver to allow method chaining when desired

func (*SliceLiteralBuilder) Build

func (b *SliceLiteralBuilder) Build() dst.Expr

Build constructs the actual dst.CompositeLit describing the slice literal

Jump to

Keyboard shortcuts

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