forked from mirror/pkger
handle main functions
This commit is contained in:
parent
7752bb822e
commit
b334bd73ac
|
@ -141,7 +141,13 @@ func Package(info here.Info, out string, decls parser.Decls) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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 \"github.com/markbates/pkger\"\n\n")
|
fmt.Fprintf(f, "import \"github.com/markbates/pkger\"\n\n")
|
||||||
fmt.Fprintf(f, "import \"github.com/markbates/pkger/pkging/mem\"\n\n")
|
fmt.Fprintf(f, "import \"github.com/markbates/pkger/pkging/mem\"\n\n")
|
||||||
fmt.Fprintf(f, "\nvar _ = pkger.Apply(mem.UnmarshalEmbed([]byte(`")
|
fmt.Fprintf(f, "\nvar _ = pkger.Apply(mem.UnmarshalEmbed([]byte(`")
|
||||||
|
|
1
go.sum
1
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/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 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
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/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 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
|
||||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||||
|
|
|
@ -41,14 +41,6 @@ func Test_Parser_Ref(t *testing.T) {
|
||||||
fmt.Println(f.Path)
|
fmt.Println(f.Path)
|
||||||
}
|
}
|
||||||
r.Len(files, 25)
|
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) {
|
func Test_Parser_Ref_Include(t *testing.T) {
|
||||||
|
@ -75,19 +67,9 @@ func Test_Parser_Ref_Include(t *testing.T) {
|
||||||
|
|
||||||
files, err := res.Files()
|
files, err := res.Files()
|
||||||
r.NoError(err)
|
r.NoError(err)
|
||||||
// t.FailNow()
|
|
||||||
|
|
||||||
l := len(files)
|
l := len(files)
|
||||||
r.Equal(26, l)
|
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) {
|
func Test_Parser_Example_HTTP(t *testing.T) {
|
||||||
|
|
|
@ -21,7 +21,6 @@ func NewRef() (*Ref, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
root := filepath.Join(
|
root := filepath.Join(
|
||||||
her.Module.Dir,
|
her.Module.Dir,
|
||||||
"pkging",
|
"pkging",
|
||||||
|
|
Loading…
Reference in New Issue