diff --git a/cmd/pkger/cmds/pack.go b/cmd/pkger/cmds/pack.go index cea99da..257e1c6 100644 --- a/cmd/pkger/cmds/pack.go +++ b/cmd/pkger/cmds/pack.go @@ -8,8 +8,8 @@ import ( "sort" "strings" + "github.com/gobuffalo/here" "github.com/markbates/pkger" - "github.com/markbates/pkger/here" "github.com/markbates/pkger/parser" "github.com/markbates/pkger/pkging/pkgutil" ) diff --git a/cmd/pkger/cmds/parse.go b/cmd/pkger/cmds/parse.go index ead6334..e9ecb3f 100644 --- a/cmd/pkger/cmds/parse.go +++ b/cmd/pkger/cmds/parse.go @@ -5,7 +5,7 @@ import ( "flag" "os" - "github.com/markbates/pkger/here" + "github.com/gobuffalo/here" "github.com/markbates/pkger/parser" ) diff --git a/cmd/pkger/cmds/path.go b/cmd/pkger/cmds/path.go index e185fff..49d4a48 100644 --- a/cmd/pkger/cmds/path.go +++ b/cmd/pkger/cmds/path.go @@ -6,8 +6,8 @@ import ( "fmt" "os" + "github.com/gobuffalo/here" "github.com/markbates/pkger" - "github.com/markbates/pkger/here" ) type pathCmd struct { diff --git a/examples/http/pkger/go.sum b/examples/http/pkger/go.sum index d5f5cec..c1a59e1 100644 --- a/examples/http/pkger/go.sum +++ b/examples/http/pkger/go.sum @@ -1,6 +1,10 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/gobuffalo/here v0.5.2-0.20191203194143-8e97fc9ad6d3 h1:9NGxHWbGFujaZ5vT+uXurb9m3QoWa175cYM2Qs97nQo= +github.com/gobuffalo/here v0.5.2-0.20191203194143-8e97fc9ad6d3/go.mod h1:wAG085dHOYqUpf+Ap+WOdrPTp5IYcDAs/x7PLa8Y5fM= +github.com/gobuffalo/here v0.6.0 h1:hYrd0a6gDmWxBM4TnrGw8mQg24iSVoIkHEk7FodQcBI= +github.com/gobuffalo/here v0.6.0/go.mod h1:wAG085dHOYqUpf+Ap+WOdrPTp5IYcDAs/x7PLa8Y5fM= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= @@ -19,3 +23,4 @@ gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/go.mod b/go.mod index 05c6854..b6a7e50 100644 --- a/go.mod +++ b/go.mod @@ -3,9 +3,6 @@ module github.com/markbates/pkger go 1.13 require ( - github.com/davecgh/go-spew v1.1.1 // indirect - github.com/kr/pretty v0.1.0 // indirect + github.com/gobuffalo/here v0.6.0 github.com/stretchr/testify v1.4.0 - gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect - gopkg.in/yaml.v2 v2.2.5 // indirect ) diff --git a/go.sum b/go.sum index c67dc0a..4cc976b 100644 --- a/go.sum +++ b/go.sum @@ -1,6 +1,8 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/gobuffalo/here v0.6.0 h1:hYrd0a6gDmWxBM4TnrGw8mQg24iSVoIkHEk7FodQcBI= +github.com/gobuffalo/here v0.6.0/go.mod h1:wAG085dHOYqUpf+Ap+WOdrPTp5IYcDAs/x7PLa8Y5fM= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= @@ -8,6 +10,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= @@ -16,5 +19,5 @@ gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33 gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.5 h1:ymVxjfMaHvXD8RqPRmzHHsB3VvucivSkIAvJFDI5O3c= -gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.7 h1:VUgggvou5XRW9mHwD/yXxIYSMtY0zoKQf/v226p2nyo= +gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/here/current.go b/here/current.go deleted file mode 100644 index cd5ee61..0000000 --- a/here/current.go +++ /dev/null @@ -1,29 +0,0 @@ -package here - -import ( - "path/filepath" - "sync" -) - -var curOnce sync.Once -var curErr error -var current Info - -func Current() (Info, error) { - (&curOnce).Do(func() { - b, err := run("go", "env", "GOMOD") - if err != nil { - curErr = err - return - } - root := filepath.Dir(string(b)) - i, err := Dir(root) - if err != nil { - curErr = err - return - } - current = i - }) - - return current, curErr -} diff --git a/here/dir.go b/here/dir.go deleted file mode 100644 index b2d3b49..0000000 --- a/here/dir.go +++ /dev/null @@ -1,77 +0,0 @@ -package here - -import ( - "encoding/json" - "fmt" - "os" - "path/filepath" -) - -// Dir attempts to gather info for the requested directory. -func Dir(p string) (Info, error) { - i, err := Cache(p, func(p string) (Info, error) { - var i Info - - fi, err := os.Stat(p) - if err != nil { - return i, err - } - - if !fi.IsDir() { - p = filepath.Dir(p) - } - - pwd, err := os.Getwd() - if err != nil { - return i, err - } - - defer os.Chdir(pwd) - - os.Chdir(p) - - b, err := run("go", "list", "-json") - // go: cannot find main module; see 'go help modules' - // build .: cannot find module for path . - // no Go files in - if err != nil { - if nonGoDirRx.MatchString(err.Error()) { - return fromNonGoDir(p) - } - return i, fmt.Errorf("%w %s", err, p) - } - - if err := json.Unmarshal(b, &i); err != nil { - return i, err - } - - return i, nil - }) - - if err != nil { - return i, err - } - - return Cache(i.ImportPath, func(p string) (Info, error) { - return i, nil - }) - -} - -func fromNonGoDir(dir string) (Info, error) { - i := Info{ - Dir: dir, - Name: filepath.Base(dir), - } - - b, err := run("go", "list", "-json", "-m") - if err != nil { - return i, err - } - - if err := json.Unmarshal(b, &i.Module); err != nil { - return i, err - } - - return i, err -} diff --git a/here/dir_test.go b/here/dir_test.go deleted file mode 100644 index 421d0be..0000000 --- a/here/dir_test.go +++ /dev/null @@ -1,67 +0,0 @@ -package here_test - -import ( - "os" - "path/filepath" - "testing" - - "github.com/markbates/pkger/here" - "github.com/markbates/pkger/pkging/pkgtest" - "github.com/stretchr/testify/require" -) - -func Test_Dir(t *testing.T) { - r := require.New(t) - - ref, err := pkgtest.NewRef() - r.NoError(err) - - root := ref.Dir - - r.NoError(err) - defer os.RemoveAll(root) - - public := filepath.Join(root, "public") - r.NoError(os.MkdirAll(public, 0755)) - - gf := filepath.Join(root, "cmd", "main.go") - r.NoError(os.MkdirAll(filepath.Dir(gf), 0755)) - - f, err := os.Create(gf) - r.NoError(err) - - _, err = f.Write([]byte("package main")) - r.NoError(err) - - r.NoError(f.Close()) - - table := []struct { - in string - err bool - }{ - {in: root, err: false}, - {in: public, err: false}, - {in: gf, err: false}, - {in: filepath.Join(root, "."), err: false}, - {in: "/unknown", err: true}, - } - for _, tt := range table { - t.Run(tt.in, func(st *testing.T) { - here.ClearCache() - r := require.New(st) - - info, err := here.Dir(tt.in) - if tt.err { - r.Error(err) - return - } - r.NoError(err) - - r.NotZero(info) - r.NotZero(info.Dir) - r.NotZero(info.Name) - r.NotZero(info.Module) - - }) - } -} diff --git a/here/here.go b/here/here.go index a825f63..81d349c 100644 --- a/here/here.go +++ b/here/here.go @@ -1,49 +1,13 @@ package here import ( - "bytes" - "fmt" - "os/exec" - "regexp" - "strings" - "sync" + "github.com/gobuffalo/here" ) -var cache = &infoMap{ - data: &sync.Map{}, -} +type Info = here.Info +type Module = here.Module +type Path = here.Path -func run(n string, args ...string) ([]byte, error) { - c := exec.Command(n, args...) - - bb := &bytes.Buffer{} - c.Stdout = bb - c.Stderr = bb - err := c.Run() - if err != nil { - return nil, fmt.Errorf("%w: %q: %s", err, strings.Join(c.Args, " "), bb) - } - - return bb.Bytes(), nil -} - -func Cache(p string, fn func(string) (Info, error)) (Info, error) { - i, ok := cache.Load(p) - if ok { - return i, nil - } - i, err := fn(p) - if err != nil { - return i, err - } - cache.Store(p, i) - return i, nil -} - -func ClearCache() { - cache = &infoMap{ - data: &sync.Map{}, - } -} - -var nonGoDirRx = regexp.MustCompile(`cannot find main|go help modules|go: |build .:|no Go files|can't load package`) +var Dir = here.Dir +var Package = here.Package +var Current = here.Current diff --git a/here/here_test.go b/here/here_test.go deleted file mode 100644 index 1f19112..0000000 --- a/here/here_test.go +++ /dev/null @@ -1,33 +0,0 @@ -package here - -import ( - "testing" - - "github.com/stretchr/testify/require" -) - -func Test_nonGoDirRx(t *testing.T) { - r := require.New(t) - r.False(nonGoDirRx.MatchString("")) - r.False(nonGoDirRx.MatchString("hello")) - - table := []string{ - "go: cannot find main module; see 'go help modules'", - "go help modules", - "go: ", - "build .:", - "no Go files", - "can't load package: package", - } - - for _, tt := range table { - t.Run(tt, func(st *testing.T) { - r := require.New(st) - - b := nonGoDirRx.MatchString(tt) - r.True(b) - - }) - } - -} diff --git a/here/info.go b/here/info.go deleted file mode 100644 index 66283ef..0000000 --- a/here/info.go +++ /dev/null @@ -1,39 +0,0 @@ -package here - -import ( - "encoding/json" -) - -// Info represents details about the directory/package -type Info struct { - Dir string - ImportPath string - Name string - Module Module -} - -func (i Info) MarshalJSON() ([]byte, error) { - mm := map[string]interface{}{ - "ImportPath": i.ImportPath, - "Name": i.Name, - "Module": i.Module, - "Dir": i.Dir, - } - - return json.Marshal(mm) -} - -// IsZero checks if the type has been filled -// with rich chocolately data goodness -func (i Info) IsZero() bool { - return i.String() == Info{}.String() -} - -func (i Info) String() string { - b, err := json.MarshalIndent(i, "", " ") - if err != nil { - return err.Error() - } - s := string(b) - return s -} diff --git a/here/info_map.go b/here/info_map.go deleted file mode 100644 index b9471ef..0000000 --- a/here/info_map.go +++ /dev/null @@ -1,87 +0,0 @@ -// Code generated by github.com/gobuffalo/mapgen. DO NOT EDIT. - -package here - -import ( - "sort" - "sync" -) - -// infoMap wraps sync.Map and uses the following types: -// key: string -// value: Info -type infoMap struct { - data *sync.Map -} - -// Delete the key from the map -func (m *infoMap) Delete(key string) { - m.data.Delete(key) -} - -// Load the key from the map. -// Returns Info or bool. -// A false return indicates either the key was not found -// or the value is not of type Info -func (m *infoMap) Load(key string) (Info, bool) { - i, ok := m.data.Load(key) - if !ok { - return Info{}, false - } - s, ok := i.(Info) - return s, ok -} - -// LoadOrStore will return an existing key or -// store the value if not already in the map -func (m *infoMap) LoadOrStore(key string, value Info) (Info, bool) { - i, _ := m.data.LoadOrStore(key, value) - s, ok := i.(Info) - return s, ok -} - -// LoadOr will return an existing key or -// run the function and store the results -func (m *infoMap) LoadOr(key string, fn func(*infoMap) (Info, bool)) (Info, bool) { - i, ok := m.Load(key) - if ok { - return i, ok - } - i, ok = fn(m) - if ok { - m.Store(key, i) - return i, ok - } - return i, false -} - -// Range over the Info values in the map -func (m *infoMap) Range(f func(key string, value Info) bool) { - m.data.Range(func(k, v interface{}) bool { - key, ok := k.(string) - if !ok { - return false - } - value, ok := v.(Info) - if !ok { - return false - } - return f(key, value) - }) -} - -// Store a Info in the map -func (m *infoMap) Store(key string, value Info) { - m.data.Store(key, value) -} - -// Keys returns a list of keys in the map -func (m *infoMap) Keys() []string { - var keys []string - m.Range(func(key string, value Info) bool { - keys = append(keys, key) - return true - }) - sort.Strings(keys) - return keys -} diff --git a/here/module.go b/here/module.go deleted file mode 100644 index bdfb969..0000000 --- a/here/module.go +++ /dev/null @@ -1,25 +0,0 @@ -package here - -import ( - "encoding/json" -) - -type Module struct { - Path string - Main bool - Dir string - GoMod string - GoVersion string -} - -func (i Module) String() string { - b, err := json.MarshalIndent(i, "", " ") - if err != nil { - return err.Error() - } - return string(b) -} - -func (i Module) IsZero() bool { - return i.String() == Module{}.String() -} diff --git a/here/parse.go b/here/parse.go deleted file mode 100644 index 9227b93..0000000 --- a/here/parse.go +++ /dev/null @@ -1,63 +0,0 @@ -package here - -import ( - "fmt" - "path/filepath" - "regexp" - "strings" -) - -func (i Info) Parse(p string) (Path, error) { - p = strings.TrimSpace(p) - p = filepath.Clean(p) - p = strings.TrimPrefix(p, i.Dir) - - p = strings.Replace(p, "\\", "/", -1) - p = strings.TrimSpace(p) - - if len(p) == 0 || p == ":" || p == "." { - return i.build("", "", "") - } - - res := pathrx.FindAllStringSubmatch(p, -1) - if len(res) == 0 { - return Path{}, fmt.Errorf("could not parse %q", p) - } - - matches := res[0] - - if len(matches) != 4 { - return Path{}, fmt.Errorf("could not parse %q", p) - } - - return i.build(p, matches[1], matches[3]) -} - -func (i Info) build(p, pkg, name string) (Path, error) { - pt := Path{ - Pkg: pkg, - Name: name, - } - - if strings.HasPrefix(pt.Pkg, "/") || len(pt.Pkg) == 0 { - pt.Name = pt.Pkg - pt.Pkg = i.Module.Path - } - - if len(pt.Name) == 0 { - pt.Name = "/" - } - - if pt.Pkg == pt.Name { - pt.Pkg = i.Module.Path - pt.Name = "/" - } - - if !strings.HasPrefix(pt.Name, "/") { - pt.Name = "/" + pt.Name - } - pt.Name = strings.TrimPrefix(pt.Name, i.Dir) - return pt, nil -} - -var pathrx = regexp.MustCompile("([^:]+)(:(/.+))?") diff --git a/here/parse_test.go b/here/parse_test.go deleted file mode 100644 index b091511..0000000 --- a/here/parse_test.go +++ /dev/null @@ -1,63 +0,0 @@ -package here_test - -import ( - "os" - "path/filepath" - "strings" - "testing" - - "github.com/markbates/pkger/here" - "github.com/markbates/pkger/pkging/pkgtest" - "github.com/stretchr/testify/require" -) - -func Test_Info_Parse(t *testing.T) { - const name = "/public/index.html" - - r := require.New(t) - - app, err := pkgtest.NewRef() - r.NoError(err) - defer os.RemoveAll(app.Dir) - - ip := app.Info.ImportPath - ip2 := "another/app" - - table := []struct { - in string - exp here.Path - err bool - }{ - {in: name, exp: here.Path{Pkg: ip, Name: name}}, - {in: "", exp: here.Path{Pkg: ip, Name: "/"}}, - {in: "/", exp: here.Path{Pkg: ip, Name: "/"}}, - {in: filepath.Join(app.Info.Dir, name), exp: here.Path{Pkg: ip, Name: name}}, - {in: ":" + name, exp: here.Path{Pkg: ip, Name: name}}, - {in: ip + ":" + name, exp: here.Path{Pkg: ip, Name: name}}, - {in: ip, exp: here.Path{Pkg: ip, Name: "/"}}, - {in: ":", exp: here.Path{Pkg: ip, Name: "/"}}, - {in: ip2 + ":" + name, exp: here.Path{Pkg: ip2, Name: name}}, - {in: ip2, exp: here.Path{Pkg: ip2, Name: "/"}}, - {in: ip2 + ":", exp: here.Path{Pkg: ip2, Name: "/"}}, - {in: filepath.Join(app.Info.Dir, "public"), exp: here.Path{Pkg: ip, Name: "/public"}}, - } - - for _, tt := range table { - for _, in := range []string{tt.in, strings.ReplaceAll(tt.in, "/", "\\")} { - t.Run(in, func(st *testing.T) { - r := require.New(st) - - pt, err := app.Info.Parse(in) - - if tt.err { - r.Error(err) - return - } - r.NoError(err) - - r.Equal(tt.exp, pt) - - }) - } - } -} diff --git a/here/path.go b/here/path.go deleted file mode 100644 index b3b3ad0..0000000 --- a/here/path.go +++ /dev/null @@ -1,20 +0,0 @@ -package here - -import ( - "fmt" -) - -type Path struct { - Pkg string - Name string -} - -func (p Path) String() string { - if p.Name == "" { - p.Name = "/" - } - if p.Pkg == "" { - return p.Name - } - return fmt.Sprintf("%s:%s", p.Pkg, p.Name) -} diff --git a/here/pkg.go b/here/pkg.go deleted file mode 100644 index 9d51c07..0000000 --- a/here/pkg.go +++ /dev/null @@ -1,44 +0,0 @@ -package here - -import ( - "encoding/json" - "fmt" -) - -// Package attempts to gather info for the requested package. -// -// From the `go help list` docs: -// The -find flag causes list to identify the named packages but not -// resolve their dependencies: the Imports and Deps lists will be empty. -// -// A workaround for this issue is to use the `Dir` field in the -// returned `Info` value and pass it to the `Dir(string) (Info, error)` -// function to return the complete data. -func Package(p string) (Info, error) { - i, err := Cache(p, func(p string) (Info, error) { - var i Info - if len(p) == 0 || p == "." { - return i, fmt.Errorf("missing package name") - } - b, err := run("go", "list", "-json", "-find", p) - if err != nil { - return i, err - } - if err := json.Unmarshal(b, &i); err != nil { - return i, err - } - - return i, nil - }) - - if err != nil { - return i, err - } - - Cache(i.Dir, func(p string) (Info, error) { - return i, nil - }) - - return i, nil - -} diff --git a/internal/maps/files.go b/internal/maps/files.go index 3b3b6ac..fd32fff 100644 --- a/internal/maps/files.go +++ b/internal/maps/files.go @@ -8,7 +8,7 @@ import ( "sort" "sync" - "github.com/markbates/pkger/here" + "github.com/gobuffalo/here" "github.com/markbates/pkger/pkging" ) diff --git a/internal/maps/infos.go b/internal/maps/infos.go index 0eed02f..cfc0604 100644 --- a/internal/maps/infos.go +++ b/internal/maps/infos.go @@ -8,7 +8,7 @@ import ( "sort" "sync" - "github.com/markbates/pkger/here" + "github.com/gobuffalo/here" ) // Infos wraps sync.Map and uses the following types: diff --git a/parser/file.go b/parser/file.go index 4b626ed..45c9748 100644 --- a/parser/file.go +++ b/parser/file.go @@ -3,7 +3,7 @@ package parser import ( "encoding/json" - "github.com/markbates/pkger/here" + "github.com/gobuffalo/here" ) type File struct { diff --git a/parser/parser.go b/parser/parser.go index 99f6ce2..4244b1c 100644 --- a/parser/parser.go +++ b/parser/parser.go @@ -11,7 +11,7 @@ import ( "strings" "sync" - "github.com/markbates/pkger/here" + "github.com/gobuffalo/here" ) var defaultIgnoredFolders = []string{".", "_", "vendor", "node_modules", "testdata"} diff --git a/parser/parser_test.go b/parser/parser_test.go index 65a0ccc..700e51b 100644 --- a/parser/parser_test.go +++ b/parser/parser_test.go @@ -8,7 +8,7 @@ import ( "strings" "testing" - "github.com/markbates/pkger/here" + "github.com/gobuffalo/here" "github.com/markbates/pkger/pkging/pkgtest" "github.com/markbates/pkger/pkging/stdos" "github.com/stretchr/testify/require" @@ -58,7 +58,6 @@ func Test_Parser_Ref_Include(t *testing.T) { }() r := require.New(t) - here.ClearCache() ref, err := pkgtest.NewRef() r.NoError(err) defer os.RemoveAll(ref.Dir) @@ -93,7 +92,6 @@ func Test_Parser_Ref_Include(t *testing.T) { func Test_Parser_Example_HTTP(t *testing.T) { r := require.New(t) - here.ClearCache() cur, err := here.Package("github.com/markbates/pkger") r.NoError(err) diff --git a/parser/source.go b/parser/source.go index 276f632..02e2b8d 100644 --- a/parser/source.go +++ b/parser/source.go @@ -8,7 +8,7 @@ import ( "strconv" "sync" - "github.com/markbates/pkger/here" + "github.com/gobuffalo/here" ) type Source struct { diff --git a/parser/walk.go b/parser/walk.go index eed6d91..51343b0 100644 --- a/parser/walk.go +++ b/parser/walk.go @@ -7,7 +7,7 @@ import ( "path/filepath" "strings" - "github.com/markbates/pkger/here" + "github.com/gobuffalo/here" ) var _ Decl = WalkDecl{} diff --git a/pkger.go b/pkger.go index 5f56a51..96d1c32 100644 --- a/pkger.go +++ b/pkger.go @@ -6,7 +6,7 @@ import ( "path/filepath" "sync" - "github.com/markbates/pkger/here" + "github.com/gobuffalo/here" "github.com/markbates/pkger/pkging" "github.com/markbates/pkger/pkging/stdos" ) diff --git a/pkging/embed/embed.go b/pkging/embed/embed.go index 29dfdf5..25d6838 100644 --- a/pkging/embed/embed.go +++ b/pkging/embed/embed.go @@ -6,7 +6,7 @@ import ( "encoding/hex" "io" - "github.com/markbates/pkger/here" + "github.com/gobuffalo/here" "github.com/markbates/pkger/internal/takeon/github.com/markbates/hepa" "github.com/markbates/pkger/internal/takeon/github.com/markbates/hepa/filters" ) diff --git a/pkging/embed/file.go b/pkging/embed/file.go index af239f8..964af15 100644 --- a/pkging/embed/file.go +++ b/pkging/embed/file.go @@ -1,7 +1,7 @@ package embed import ( - "github.com/markbates/pkger/here" + "github.com/gobuffalo/here" "github.com/markbates/pkger/pkging" ) diff --git a/pkging/file.go b/pkging/file.go index c7d12a1..6d49cca 100644 --- a/pkging/file.go +++ b/pkging/file.go @@ -4,7 +4,7 @@ import ( "net/http" "os" - "github.com/markbates/pkger/here" + "github.com/gobuffalo/here" ) type File interface { diff --git a/pkging/file_info_test.go b/pkging/file_info_test.go index 6751c0e..c0c3fec 100644 --- a/pkging/file_info_test.go +++ b/pkging/file_info_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - "github.com/markbates/pkger/here" + "github.com/gobuffalo/here" "github.com/markbates/pkger/pkging" "github.com/stretchr/testify/require" ) diff --git a/pkging/mem/add.go b/pkging/mem/add.go index 56fe549..b21c2d5 100644 --- a/pkging/mem/add.go +++ b/pkging/mem/add.go @@ -6,7 +6,7 @@ import ( "os" "path/filepath" - "github.com/markbates/pkger/here" + "github.com/gobuffalo/here" "github.com/markbates/pkger/pkging" ) @@ -19,7 +19,6 @@ func (fx *Pkger) Add(files ...*os.File) error { if err != nil { return err } - pt, err := fx.Parse(f.Name()) if err != nil { return err diff --git a/pkging/mem/add_test.go b/pkging/mem/add_test.go index 342d048..924d753 100644 --- a/pkging/mem/add_test.go +++ b/pkging/mem/add_test.go @@ -5,7 +5,7 @@ import ( "path/filepath" "testing" - "github.com/markbates/pkger/here" + "github.com/gobuffalo/here" "github.com/markbates/pkger/pkging/mem" "github.com/stretchr/testify/require" ) diff --git a/pkging/mem/embed.go b/pkging/mem/embed.go index a7086ed..76e1db7 100644 --- a/pkging/mem/embed.go +++ b/pkging/mem/embed.go @@ -3,7 +3,7 @@ package mem import ( "encoding/json" - "github.com/markbates/pkger/here" + "github.com/gobuffalo/here" "github.com/markbates/pkger/internal/maps" "github.com/markbates/pkger/pkging" "github.com/markbates/pkger/pkging/embed" diff --git a/pkging/mem/file.go b/pkging/mem/file.go index 2d4d244..18fd2b8 100644 --- a/pkging/mem/file.go +++ b/pkging/mem/file.go @@ -10,7 +10,7 @@ import ( "path/filepath" "time" - "github.com/markbates/pkger/here" + "github.com/gobuffalo/here" "github.com/markbates/pkger/pkging" ) diff --git a/pkging/mem/file_test.go b/pkging/mem/file_test.go index 5ebb32b..986c7fb 100644 --- a/pkging/mem/file_test.go +++ b/pkging/mem/file_test.go @@ -4,7 +4,7 @@ import ( "io/ioutil" "testing" - "github.com/markbates/pkger/here" + "github.com/gobuffalo/here" "github.com/stretchr/testify/require" ) diff --git a/pkging/mem/mem.go b/pkging/mem/mem.go index 1590e3e..dfa3a99 100644 --- a/pkging/mem/mem.go +++ b/pkging/mem/mem.go @@ -8,7 +8,7 @@ import ( "strings" "time" - "github.com/markbates/pkger/here" + "github.com/gobuffalo/here" "github.com/markbates/pkger/internal/maps" "github.com/markbates/pkger/pkging" ) diff --git a/pkging/pkger.go b/pkging/pkger.go index b2076f6..4a7a2fa 100644 --- a/pkging/pkger.go +++ b/pkging/pkger.go @@ -4,7 +4,7 @@ import ( "os" "path/filepath" - "github.com/markbates/pkger/here" + "github.com/gobuffalo/here" ) type Pkger interface { diff --git a/pkging/pkgtest/load_ref.go b/pkging/pkgtest/load_ref.go index e04ce7b..331b093 100644 --- a/pkging/pkgtest/load_ref.go +++ b/pkging/pkgtest/load_ref.go @@ -7,7 +7,7 @@ import ( "path/filepath" "strings" - "github.com/markbates/pkger/here" + "github.com/gobuffalo/here" "github.com/markbates/pkger/pkging" ) diff --git a/pkging/pkgtest/pkgtest.go b/pkging/pkgtest/pkgtest.go index d852fda..11585b7 100644 --- a/pkging/pkgtest/pkgtest.go +++ b/pkging/pkgtest/pkgtest.go @@ -5,7 +5,7 @@ import ( "os" "testing" - "github.com/markbates/pkger/here" + "github.com/gobuffalo/here" "github.com/markbates/pkger/pkging" "github.com/stretchr/testify/require" ) diff --git a/pkging/pkgtest/ref.go b/pkging/pkgtest/ref.go index a9a8dca..84e9ba9 100644 --- a/pkging/pkgtest/ref.go +++ b/pkging/pkgtest/ref.go @@ -8,7 +8,7 @@ import ( "path/filepath" "runtime" - "github.com/markbates/pkger/here" + "github.com/gobuffalo/here" ) type Ref struct { diff --git a/pkging/pkgtest/testdata/ref/go.sum b/pkging/pkgtest/testdata/ref/go.sum index a243cab..37f7a77 100644 --- a/pkging/pkgtest/testdata/ref/go.sum +++ b/pkging/pkgtest/testdata/ref/go.sum @@ -1,6 +1,10 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/gobuffalo/here v0.5.2-0.20191203194143-8e97fc9ad6d3 h1:9NGxHWbGFujaZ5vT+uXurb9m3QoWa175cYM2Qs97nQo= +github.com/gobuffalo/here v0.5.2-0.20191203194143-8e97fc9ad6d3/go.mod h1:wAG085dHOYqUpf+Ap+WOdrPTp5IYcDAs/x7PLa8Y5fM= +github.com/gobuffalo/here v0.6.0 h1:hYrd0a6gDmWxBM4TnrGw8mQg24iSVoIkHEk7FodQcBI= +github.com/gobuffalo/here v0.6.0/go.mod h1:wAG085dHOYqUpf+Ap+WOdrPTp5IYcDAs/x7PLa8Y5fM= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= @@ -18,3 +22,4 @@ gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/pkging/pkgutil/dump.go b/pkging/pkgutil/dump.go index 128161a..ce23c82 100644 --- a/pkging/pkgutil/dump.go +++ b/pkging/pkgutil/dump.go @@ -6,7 +6,7 @@ import ( "io" "os" - "github.com/markbates/pkger/here" + "github.com/gobuffalo/here" "github.com/markbates/pkger/pkging" ) diff --git a/pkging/pkgutil/stuff.go b/pkging/pkgutil/stuff.go index c580c4e..434e85c 100644 --- a/pkging/pkgutil/stuff.go +++ b/pkging/pkgutil/stuff.go @@ -4,7 +4,7 @@ import ( "io" "os" - "github.com/markbates/pkger/here" + "github.com/gobuffalo/here" "github.com/markbates/pkger/parser" "github.com/markbates/pkger/pkging/embed" "github.com/markbates/pkger/pkging/mem" diff --git a/pkging/pkgutil/stuff_test.go b/pkging/pkgutil/stuff_test.go index 681d3f4..68502fa 100644 --- a/pkging/pkgutil/stuff_test.go +++ b/pkging/pkgutil/stuff_test.go @@ -19,6 +19,12 @@ func Test_Stuff(t *testing.T) { r.NoError(err) defer os.RemoveAll(ref.Dir) + pwd, err := os.Getwd() + r.NoError(err) + defer os.Chdir(pwd) + + os.Chdir(ref.Dir) + disk, err := stdos.New(ref.Info) r.NoError(err) diff --git a/pkging/stdos/file.go b/pkging/stdos/file.go index 35845cf..51559f8 100644 --- a/pkging/stdos/file.go +++ b/pkging/stdos/file.go @@ -5,7 +5,7 @@ import ( "os" "path" - "github.com/markbates/pkger/here" + "github.com/gobuffalo/here" "github.com/markbates/pkger/pkging" ) diff --git a/pkging/stdos/file_test.go b/pkging/stdos/file_test.go index a33f29d..9a475bd 100644 --- a/pkging/stdos/file_test.go +++ b/pkging/stdos/file_test.go @@ -3,7 +3,7 @@ package stdos import ( "testing" - "github.com/markbates/pkger/here" + "github.com/gobuffalo/here" "github.com/stretchr/testify/require" ) diff --git a/pkging/stdos/stdos.go b/pkging/stdos/stdos.go index 75777c3..ce34624 100644 --- a/pkging/stdos/stdos.go +++ b/pkging/stdos/stdos.go @@ -6,7 +6,7 @@ import ( "path/filepath" "strings" - "github.com/markbates/pkger/here" + "github.com/gobuffalo/here" "github.com/markbates/pkger/internal/maps" "github.com/markbates/pkger/pkging" ) diff --git a/pkging/wrap.go b/pkging/wrap.go index 438f955..dee4b0a 100644 --- a/pkging/wrap.go +++ b/pkging/wrap.go @@ -5,7 +5,7 @@ import ( "os" "path/filepath" - "github.com/markbates/pkger/here" + "github.com/gobuffalo/here" ) func Wrap(parent, with Pkger) Pkger {