mirror of https://github.com/markbates/pkger.git
Merge pull request #80 from taiyangc/master
Fix pkger generating the wrong package name for pkger.go
This commit is contained in:
commit
a78c11e368
|
@ -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(`")
|
||||
|
|
Loading…
Reference in New Issue