-
Notifications
You must be signed in to change notification settings - Fork 61
Open
Description
I'm trying to generate some code using dst package.
Part of the code involves multi-line string literal.
I'd like to keep the code prettier by propagating the indentation level into the string literal
... // node :=
&dst.CallExpr{
Fun: &dst.SelectorExpr{
X: &dst.Ident{Name: "mypackage"},
Sel: &dst.Ident{Name: "MyFunc"},
},
Args: []dst.Expr{
&dst.BasicLit{
Kind: token.STRING,
Value: fmt.Sprintf("`\n%v\n`", "multi\nline\nliteral"),
},
},
},The generated code will look like
func GeneratedFunc() {
node := mypackage.MyFunc(`
multi
line
literal
`) // <-- This non-indent looks rather bothering
}Is it possible that I can make the string literal indent aligned with the caller, or somehow retrieve the 'indentation level' via the dst package, so that I can manually Tweak the literal? e.g.
func GeneratedFunc() {
node := mypackage.MyFunc(`
multi
line
literal
`)
}Metadata
Metadata
Assignees
Labels
No labels