Skip to content

Commit

Permalink
Revert "remove generated file"
Browse files Browse the repository at this point in the history
This reverts commit b2c88c3.
  • Loading branch information
crhntr committed Aug 19, 2024
1 parent 532fe62 commit baa87f3
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions cmd/muxt/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package main
import (
"flag"
"fmt"
"go/ast"
"go/token"
"io"
"log"
Expand Down Expand Up @@ -74,6 +73,7 @@ func generateCommand(args []string, workingDirectory string, getEnv func(string)
if err != nil {
return err
}
_ = os.Remove(filepath.Join(workingDirectory, g.outputFilename))
list, err := packages.Load(&packages.Config{
Mode: packages.NeedFiles | packages.NeedSyntax | packages.NeedEmbedPatterns | packages.NeedEmbedFiles,
Dir: workingDirectory,
Expand Down Expand Up @@ -101,14 +101,7 @@ func generateCommand(args []string, workingDirectory string, getEnv func(string)
return err
}
out := log.New(stdout, "", 0)
files := slices.Clone(g.Package.Syntax)
if i := slices.IndexFunc(files, func(file *ast.File) bool {
p := g.Package.Fset.Position(file.Pos())
return p.Filename == g.outputFilename
}); i >= 0 {
files = slices.Clip(slices.Delete(files, i, i+1))
}
s, err := muxt.Generate(templateNames, g.goPackage, g.templatesVariable, g.routesFunction, g.receiverIdent, g.Package.Fset, files, files, out)
s, err := muxt.Generate(templateNames, g.goPackage, g.templatesVariable, g.routesFunction, g.receiverIdent, g.Package.Fset, g.Package.Syntax, g.Package.Syntax, out)
if err != nil {
return err
}
Expand Down

0 comments on commit baa87f3

Please sign in to comment.