Skip to content

Commit

Permalink
Add support for go:embed in stringifyVarDecl function
Browse files Browse the repository at this point in the history
  • Loading branch information
koki-develop committed Mar 6, 2024
1 parent acd826a commit 15c91ff
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions internal/mingo/decl.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,15 @@ func (m *mingo) stringifyConstDecl(decl *ast.GenDecl) string {

func (m *mingo) stringifyVarDecl(decl *ast.GenDecl) string {
sb := new(strings.Builder)

if decl.Doc != nil {
for _, cmt := range decl.Doc.List {
if strings.HasPrefix(cmt.Text, "//go:embed ") {
fmt.Fprintf(sb, "\n%s\n", cmt.Text)
}
}
}

sb.WriteString("var")

if len(decl.Specs) > 1 {
Expand All @@ -128,6 +137,14 @@ func (m *mingo) stringifyVarDecl(decl *ast.GenDecl) string {
if j > 0 {
sb.WriteString(",")
}

if spec.Doc != nil {
for _, cmt := range spec.Doc.List {
if strings.HasPrefix(cmt.Text, "//go:embed ") {
fmt.Fprintf(sb, "\n%s\n", cmt.Text)
}
}
}
sb.WriteString(name.Name)
}

Expand Down

0 comments on commit 15c91ff

Please sign in to comment.