don't get me wrong

This commit is contained in:
Mark Bates 2019-10-15 17:12:46 -04:00
parent 9858775ba7
commit 33e29b61f4
6 changed files with 21 additions and 33 deletions

View File

@ -580,6 +580,7 @@ github.com/markbates/deplist v1.0.5/go.mod h1:gRRbPbbuA8TmMiRvaOzUlRfzfjeCCBqX2A
github.com/markbates/deplist v1.1.3/go.mod h1:BF7ioVzAJYEtzQN/os4rt8H8Ti3h0T7EoN+7eyALktE=
github.com/markbates/deplist v1.2.0/go.mod h1:dtsWLZ5bWoazbM0rCxZncQaAPifWbvHgBJk8UNI1Yfk=
github.com/markbates/deplist v1.3.0/go.mod h1:dtsWLZ5bWoazbM0rCxZncQaAPifWbvHgBJk8UNI1Yfk=
github.com/markbates/errx v1.1.0 h1:QDFeR+UP95dO12JgW+tgi2UVfo0V8YBHiUIOaeBPiEI=
github.com/markbates/errx v1.1.0/go.mod h1:PLa46Oex9KNbVDZhKel8v1OT7hD5JZ2eI7AHhA0wswc=
github.com/markbates/going v1.0.2/go.mod h1:UWCk3zm0UKefHZ7l8BNqi26UyiEMniznk8naLdTcy6c=
github.com/markbates/going v1.0.3/go.mod h1:fQiT6v6yQar9UD6bd/D4Z5Afbk9J6BBVBtLiyY4gp2o=

View File

@ -43,7 +43,7 @@ func main() {
// : - seperator between the module/package name, pkg, and the "file path"
// path - this is the ABSOLUTE path to the file/directory you want, as relative
// to the root of the module/package's go.mod file.
dir, err := pkger.Open("github.com/markbates/pkger/examples/app:/public")
dir, err := pkger.Open("github.com/gobuffalo/buffalo:/plugins")
if err != nil {
log.Fatal(err)
}

3
go.sum
View File

@ -268,6 +268,7 @@ github.com/gobuffalo/httptest v1.0.6/go.mod h1:7T1IbSrg60ankme0aDLVnEY0h056g9M1/
github.com/gobuffalo/httptest v1.1.0/go.mod h1:BIfCgiqCOotRc5xYwCcZN7IFYag4277Ynqjar/Ra3iI=
github.com/gobuffalo/httptest v1.2.0/go.mod h1:0KfourZCsapuvkljDMSr7YM+66kCt/rXv54YcWRWwhc=
github.com/gobuffalo/httptest v1.3.0/go.mod h1:Y4qebOsMH91XdB0cZuS8OUdAKHGV7hVDcjgzGupoYlk=
github.com/gobuffalo/httptest v1.4.0 h1:DaoTl/2iFRTk9Uau6b0Lh644tcbRtBNMHcWg6WhieS8=
github.com/gobuffalo/httptest v1.4.0/go.mod h1:VDkgCFmIxAunkLNts49TC949NRLTtvyLKuN67o6hrXM=
github.com/gobuffalo/licenser v0.0.0-20180924033006-eae28e638a42/go.mod h1:Ubo90Np8gpsSZqNScZZkVXXAo5DGhTb+WYFIjlnog8w=
github.com/gobuffalo/licenser v0.0.0-20181025145548-437d89de4f75/go.mod h1:x3lEpYxkRG/XtGCUNkio+6RZ/dlOvLzTI9M1auIwFcw=
@ -367,6 +368,7 @@ github.com/gobuffalo/packr v1.21.9/go.mod h1:GC76q6nMzRtR+AEN/VV4w0z2/4q7SOaEmXh
github.com/gobuffalo/packr v1.22.0/go.mod h1:Qr3Wtxr3+HuQEwWqlLnNW4t1oTvK+7Gc/Rnoi/lDFvA=
github.com/gobuffalo/packr v1.24.0/go.mod h1:p9Sgang00I1hlr1ub+tgI9AQdFd4f+WH1h62jYpzetM=
github.com/gobuffalo/packr v1.24.1/go.mod h1:absPnW/XUUa4DmIh5ga7AipGXXg0DOcd5YWKk5RZs8Y=
github.com/gobuffalo/packr v1.25.0 h1:NtPK45yOKFdTKHTvRGKL+UIKAKmJVWIVJOZBDI/qEdY=
github.com/gobuffalo/packr v1.25.0/go.mod h1:NqsGg8CSB2ZD+6RBIRs18G7aZqdYDlYNNvsSqP6T4/U=
github.com/gobuffalo/packr/v2 v2.0.0-rc.5/go.mod h1:e6gmOfhf3KmT4zl2X/NDRSfBXk2oV4TXZ+NNOM0xwt8=
github.com/gobuffalo/packr/v2 v2.0.0-rc.7/go.mod h1:BzhceHWfF3DMAkbPUONHYWs63uacCZxygFY1b4H9N2A=
@ -392,6 +394,7 @@ github.com/gobuffalo/packr/v2 v2.4.0/go.mod h1:ra341gygw9/61nSjAbfwcwh8IrYL4WmR4
github.com/gobuffalo/packr/v2 v2.5.1/go.mod h1:8f9c96ITobJlPzI44jj+4tHnEKNt0xXWSVlXRN9X1Iw=
github.com/gobuffalo/packr/v2 v2.5.2/go.mod h1:sgEE1xNZ6G0FNN5xn9pevVu4nywaxHvgup67xisti08=
github.com/gobuffalo/packr/v2 v2.5.3/go.mod h1:sgEE1xNZ6G0FNN5xn9pevVu4nywaxHvgup67xisti08=
github.com/gobuffalo/packr/v2 v2.6.0 h1:EMUzJIb5rof6r087PtGmgdzdLKpRBESJ/8jyL9MexfY=
github.com/gobuffalo/packr/v2 v2.6.0/go.mod h1:sgEE1xNZ6G0FNN5xn9pevVu4nywaxHvgup67xisti08=
github.com/gobuffalo/plush v3.7.16+incompatible/go.mod h1:rQ4zdtUUyZNqULlc6bqd5scsPfLKfT0+TGMChgduDvI=
github.com/gobuffalo/plush v3.7.20+incompatible/go.mod h1:rQ4zdtUUyZNqULlc6bqd5scsPfLKfT0+TGMChgduDvI=

View File

@ -1,6 +1,7 @@
package mem
import (
"bytes"
"encoding/json"
"fmt"
"io"
@ -166,10 +167,12 @@ func (fx *Pkger) Add(f pkging.File) error {
}
if !info.IsDir() {
_, err = io.Copy(mf, f)
bb := &bytes.Buffer{}
_, err = io.Copy(bb, f)
if err != nil {
return err
}
mf.data = bb.Bytes()
}
fx.files.Store(mf.Path(), mf)
@ -306,6 +309,7 @@ func (fx *Pkger) Open(name string) (pkging.File, error) {
return nil, err
}
fmt.Println(">>>TODO pkging/mem/mem.go:309: pt ", pt)
fl, ok := fx.files.Load(pt)
if !ok {
return nil, fmt.Errorf("could not open %s", name)
@ -322,6 +326,8 @@ func (fx *Pkger) Open(name string) (pkging.File, error) {
her: f.her,
}
fmt.Println(">>>TODO pkging/mem/mem.go:326: nf.info ", nf.info)
return nf, nil
}

View File

@ -1,13 +1,11 @@
package mem
import (
"os"
"testing"
"github.com/markbates/pkger/here"
"github.com/markbates/pkger/pkging"
"github.com/markbates/pkger/pkging/pkgtest"
"github.com/markbates/pkger/pkging/stdos"
)
func Test_Pkger(t *testing.T) {
@ -22,32 +20,6 @@ func Test_Pkger(t *testing.T) {
return nil, err
}
disk, err := stdos.New(info)
if err != nil {
return nil, err
}
err = disk.Walk("/examples/app/public", func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
pt, err := disk.Parse(path)
if err != nil {
return err
}
f, err := disk.Open(pt.String())
if err != nil {
return err
}
defer f.Close()
if err := pkg.Add(f); err != nil {
return err
}
return nil
})
return pkg, nil
})
if err != nil {

View File

@ -1,11 +1,13 @@
package pkgtest
import (
"fmt"
"io/ioutil"
"net/http"
"net/http/httptest"
"os"
"path/filepath"
"strings"
"testing"
"github.com/markbates/pkger/pkging"
@ -184,7 +186,9 @@ func (s Suite) Test_HTTP_File(t *testing.T) {
defer os.RemoveAll(tdir)
r.NoError(s.WriteFolder(tdir))
gots := httptest.NewServer(http.FileServer(http.Dir(tdir)))
tpub := filepath.Join(tdir, "public")
fmt.Println(">>>TODO pkging/pkgtest/http.go:190: tpub ", tpub)
gots := httptest.NewServer(http.FileServer(http.Dir(tpub)))
defer gots.Close()
dir, err := pkg.Open(tt.in)
@ -198,7 +202,7 @@ func (s Suite) Test_HTTP_File(t *testing.T) {
"/",
"/index.html",
"/images",
"/images/images/mark.png",
"/images/mark.png",
}
for _, path := range paths {
@ -216,7 +220,9 @@ func (s Suite) Test_HTTP_File(t *testing.T) {
pkgbody, err := ioutil.ReadAll(pkgres.Body)
r.NoError(err)
r.Equal(string(gobody), string(pkgbody))
exp := strings.ReplaceAll(string(gobody), tdir, "")
r.Equal(exp, string(pkgbody))
})
}
})