diff --git a/cmd/pkger/cmds/pack.go b/cmd/pkger/cmds/pack.go index bbb81c9..c71d3f0 100644 --- a/cmd/pkger/cmds/pack.go +++ b/cmd/pkger/cmds/pack.go @@ -141,7 +141,13 @@ func Package(info here.Info, out string, decls parser.Decls) error { if err != nil { return err } - fmt.Fprintf(f, "package %s\n\n", c.Name) + + name := c.Name + if info.Module.Main { + name = "main" + } + + fmt.Fprintf(f, "package %s\n\n", 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(`") diff --git a/go.sum b/go.sum index c67dc0a..ade87ab 100644 --- a/go.sum +++ b/go.sum @@ -8,6 +8,7 @@ github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= diff --git a/parser/parser_test.go b/parser/parser_test.go index 65a0ccc..99ce1ca 100644 --- a/parser/parser_test.go +++ b/parser/parser_test.go @@ -41,14 +41,6 @@ func Test_Parser_Ref(t *testing.T) { fmt.Println(f.Path) } r.Len(files, 25) - - for _, f := range files { - if f.Path.Pkg == ref.Module.Path { - r.True(strings.HasPrefix(f.Abs, ref.Dir), "%q %q", f.Abs, ref.Dir) - } else { - r.False(strings.HasPrefix(f.Abs, ref.Dir), "%q %q", f.Abs, ref.Dir) - } - } } func Test_Parser_Ref_Include(t *testing.T) { @@ -75,19 +67,9 @@ func Test_Parser_Ref_Include(t *testing.T) { files, err := res.Files() r.NoError(err) - // t.FailNow() l := len(files) r.Equal(26, l) - // r.Len(files, 27) - - for _, f := range files { - if f.Path.Pkg == ref.Module.Path { - r.True(strings.HasPrefix(f.Abs, ref.Dir), "%q %q", f.Abs, ref.Dir) - } else { - r.False(strings.HasPrefix(f.Abs, ref.Dir), "%q %q", f.Abs, ref.Dir) - } - } } func Test_Parser_Example_HTTP(t *testing.T) { diff --git a/pkging/pkgtest/ref.go b/pkging/pkgtest/ref.go index a9a8dca..5fe1a0a 100644 --- a/pkging/pkgtest/ref.go +++ b/pkging/pkgtest/ref.go @@ -21,7 +21,6 @@ func NewRef() (*Ref, error) { if err != nil { return nil, err } - root := filepath.Join( her.Module.Dir, "pkging",