diff --git a/cmd/pkger/cmds/pack.go b/cmd/pkger/cmds/pack.go index 2381bd9..7973e54 100644 --- a/cmd/pkger/cmds/pack.go +++ b/cmd/pkger/cmds/pack.go @@ -124,6 +124,11 @@ func (e *packCmd) Flags() *flag.FlagSet { } func Package(info here.Info, out string, decls parser.Decls) error { + c, err := here.Dir(filepath.Dir(out)) + if err != nil { + return err + } + os.RemoveAll(out) defer func() { if err := recover(); err != nil { @@ -137,18 +142,8 @@ func Package(info here.Info, out string, decls parser.Decls) error { } defer f.Close() - c, err := here.Dir(filepath.Dir(out)) - if err != nil { - return err - } - - name := c.Name - if info.Module.Main { - name = "main" - } - fmt.Fprintf(f, "// Code generated by pkger; DO NOT EDIT.\n\n") - fmt.Fprintf(f, "package %s\n\n", name) + fmt.Fprintf(f, "package %s\n\n", c.Name) fmt.Fprintf(f, "import (\n\t\"github.com/markbates/pkger\"\n\t") fmt.Fprintf(f, "\"github.com/markbates/pkger/pkging/mem\"\n)\n\n") fmt.Fprintf(f, "var _ = pkger.Apply(mem.UnmarshalEmbed([]byte(`")