diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..65900ed --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,2 @@ +# Default owner +* @gobuffalo/core-managers \ No newline at end of file diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..d351c05 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,4 @@ +# These are supported funding model platforms + +github: markbates +patreon: buffalo \ No newline at end of file diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..fa0fac0 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,27 @@ +name: Tests +on: [push, pull_request] +jobs: + + tests: + name: ${{matrix.go-version}} ${{matrix.os}} + runs-on: ${{ matrix.os }} + strategy: + matrix: + go-version: [1.12.x, 1.13.x] + os: [macos-latest, windows-latest, ubuntu-latest] + steps: + - name: Checkout Code + uses: actions/checkout@v1 + with: + fetch-depth: 1 + - name: Test v1 + run: | + go get -t -v ./... + go test -race ./... + go install -v ./packr + - name: Test v2 + run: | + cd v2 + go get -t -v ./... + go test -race ./... + go install -v ./packr2 \ No newline at end of file diff --git a/.gitignore b/.gitignore index 157ef96..08c51e6 100644 --- a/.gitignore +++ b/.gitignore @@ -33,4 +33,5 @@ debug.test .grifter/ *-packr.go +.idea/ diff --git a/README.md b/README.md index 89529f4..f74de4c 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,8 @@ +**NOTICE: Please consider migrating your projects to [github.com/markbates/pkger](https://github.com/markbates/pkger). It has an idiomatic API, minimal dependencies, a stronger test suite (tested directly against the std lib counterparts), transparent tooling, and more.** + +https://blog.gobuffalo.io/introducing-pkger-static-file-embedding-in-go-1ce76dc79c65 + + # packr (v1) [![GoDoc](https://godoc.org/github.com/gobuffalo/packr?status.svg)](https://godoc.org/github.com/gobuffalo/packr) @@ -40,7 +45,7 @@ html, err := box.FindString("index.html") // Get the []byte representation of a file, or an error if it doesn't exist: -html, err := box.FindBytes("index.html") +html, err := box.Find("index.html") ``` ### What is a Box? diff --git a/azure-pipelines.yml b/azure-pipelines.yml deleted file mode 100644 index 417e2c5..0000000 --- a/azure-pipelines.yml +++ /dev/null @@ -1,71 +0,0 @@ -variables: - GOBIN: "$(GOPATH)/bin" # Go binaries path - GOPATH: "$(system.defaultWorkingDirectory)/gopath" # Go workspace path - modulePath: "$(GOPATH)/src/github.com/$(build.repository.name)" # Path to the module"s code - -jobs: -- job: Windows - pool: - vmImage: "vs2017-win2016" - strategy: - matrix: - go 1.10: - go_version: "1.10" - go 1.11 (on): - go_version: "1.11.5" - GO111MODULE: "on" - go 1.11 (off): - go_version: "1.11.5" - GO111MODULE: "off" - go 1.12 (on): - go_version: "1.12" - GO111MODULE: "on" - go 1.12 (off): - go_version: "1.12" - GO111MODULE: "off" - steps: - - template: azure-tests.yml - -- job: macOS - pool: - vmImage: "macOS-10.13" - strategy: - matrix: - go 1.10: - go_version: "1.10" - go 1.11 (on): - go_version: "1.11.5" - GO111MODULE: "on" - go 1.11 (off): - go_version: "1.11.5" - GO111MODULE: "off" - go 1.12 (on): - go_version: "1.12" - GO111MODULE: "on" - go 1.12 (off): - go_version: "1.12" - GO111MODULE: "off" - steps: - - template: azure-tests.yml - -- job: Linux - pool: - vmImage: "ubuntu-16.04" - strategy: - matrix: - go 1.10: - go_version: "1.10" - go 1.11 (on): - go_version: "1.11.5" - GO111MODULE: "on" - go 1.11 (off): - go_version: "1.11.5" - GO111MODULE: "off" - go 1.12 (on): - go_version: "1.12" - GO111MODULE: "on" - go 1.12 (off): - go_version: "1.12" - GO111MODULE: "off" - steps: - - template: azure-tests.yml diff --git a/azure-tests.yml b/azure-tests.yml deleted file mode 100644 index 58300d1..0000000 --- a/azure-tests.yml +++ /dev/null @@ -1,24 +0,0 @@ -steps: - - task: GoTool@0 - inputs: - version: $(go_version) - - task: Bash@3 - inputs: - targetType: inline - script: | - mkdir -p "$(GOBIN)" - mkdir -p "$(GOPATH)/pkg" - mkdir -p "$(modulePath)" - shopt -s extglob - mv !(gopath) "$(modulePath)" - displayName: "Setup Go Workspace" - - script: | - go get -t -v ./... - go test -race ./... - go install -v ./packr - cd v2 - go get -t -v ./... - go test -race ./... - go install -v ./packr2 - workingDirectory: "$(modulePath)" - displayName: "Tests" diff --git a/builder/tmpl.go b/builder/tmpl.go index 2b335ad..812420a 100644 --- a/builder/tmpl.go +++ b/builder/tmpl.go @@ -11,7 +11,7 @@ func init() { {{- range $box := .Boxes }} {{- range .Files }} - packr.PackJSONBytes("{{$box.Name}}", "{{.Name}}", "{{.Contents}}") + _ = packr.PackJSONBytes("{{$box.Name}}", "{{.Name}}", "{{.Contents}}") {{- end }} {{- end }} } diff --git a/go.mod b/go.mod index a8281f3..fcb35b3 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ require ( github.com/gobuffalo/envy v1.7.0 github.com/gobuffalo/packd v0.3.0 - github.com/gobuffalo/packr/v2 v2.5.1 + github.com/gobuffalo/packr/v2 v2.5.2 github.com/spf13/cobra v0.0.5 github.com/stretchr/testify v1.3.0 golang.org/x/sync v0.0.0-20190423024810-112230192c58 diff --git a/go.sum b/go.sum index 1628131..675c18d 100644 --- a/go.sum +++ b/go.sum @@ -14,8 +14,8 @@ github.com/gobuffalo/logger v1.0.0/go.mod h1:2zbswyIUa45I+c+FLXuWl9zSWEiVuthsk8ze5s8JvPs= github.com/gobuffalo/packd v0.3.0 h1:eMwymTkA1uXsqxS0Tpoop3Lc0u3kTfiMBE6nKtQU4g4= github.com/gobuffalo/packd v0.3.0/go.mod h1:zC7QkmNkYVGKPw4tHpBQ+ml7W/3tIebgeo1b36chA3Q= -github.com/gobuffalo/packr/v2 v2.5.1 h1:TFOeY2VoGamPjQLiNDT3mn//ytzk236VMO2j7iHxJR4= -github.com/gobuffalo/packr/v2 v2.5.1/go.mod h1:8f9c96ITobJlPzI44jj+4tHnEKNt0xXWSVlXRN9X1Iw= +github.com/gobuffalo/packr/v2 v2.5.2 h1:4EvjeIpQLZuRIljwnidYgbRXbr1yIzVRrESiLjqKj6s= +github.com/gobuffalo/packr/v2 v2.5.2/go.mod h1:sgEE1xNZ6G0FNN5xn9pevVu4nywaxHvgup67xisti08= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= @@ -71,8 +71,8 @@ golang.org/x/sys v0.0.0-20190515120540-06a5c4944438 h1:khxRGsvPk4n2y8I/mLLjp7e5dMTJmH75wvqS6nMwUtY= golang.org/x/sys v0.0.0-20190515120540-06a5c4944438/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/tools v0.0.0-20190624180213-70d37148ca0c h1:KfpJVdWhuRqNk4XVXzjXf2KAV4TBEP77SYdFGjeGuIE= -golang.org/x/tools v0.0.0-20190624180213-70d37148ca0c/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0 h1:Dh6fw+p6FyRl5x/FvNswO1ji0lIGzm3KP8Y9VkS9PTE= +golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= diff --git a/packr/cmd/version.go b/packr/cmd/version.go index df43919..470a1d5 100644 --- a/packr/cmd/version.go +++ b/packr/cmd/version.go @@ -11,7 +11,7 @@ Use: "version", Short: "prints packr version", Run: func(cmd *cobra.Command, args []string) { - fmt.Print(packr.Version) + fmt.Println(packr.Version) }, } diff --git a/v2/.goreleaser.yml b/v2/.goreleaser.yml index a0c56e8..7a57ebb 100644 --- a/v2/.goreleaser.yml +++ b/v2/.goreleaser.yml @@ -34,8 +34,9 @@ - '^docs:' - '^test:' -brew: - github: - owner: gobuffalo - name: homebrew-tap +brews: + - + github: + owner: gobuffalo + name: homebrew-tap diff --git a/v2/.goreleaser.yml.plush b/v2/.goreleaser.yml.plush index 79e030d..6bd6ba9 100644 --- a/v2/.goreleaser.yml.plush +++ b/v2/.goreleaser.yml.plush @@ -31,8 +31,9 @@ - '^docs:' - '^test:' <%= if (brew) { %> -brew: - github: - owner: gobuffalo - name: homebrew-tap +brews: + - + github: + owner: gobuffalo + name: homebrew-tap <% } %> diff --git a/v2/Makefile b/v2/Makefile index 8de26c8..0c87008 100644 --- a/v2/Makefile +++ b/v2/Makefile @@ -14,7 +14,6 @@ endif deps: - $(GO_BIN) get github.com/gobuffalo/release $(GO_BIN) get -tags ${TAGS} -t ./... $(GO_BIN) install -v ./packr2 make tidy diff --git a/v2/README.md b/v2/README.md index 6591155..cb65f9b 100644 --- a/v2/README.md +++ b/v2/README.md @@ -1,3 +1,7 @@ +**NOTICE: Please consider migrating your projects to github.com/markbates/pkger. It has an idiomatic API, minimal dependencies, a stronger test suite (tested directly against the std lib counterparts), transparent tooling, and more.** + +https://blog.gobuffalo.io/introducing-pkger-static-file-embedding-in-go-1ce76dc79c65 + # Packr (v2) [![GoDoc](https://godoc.org/github.com/gobuffalo/packr/v2?status.svg)](https://godoc.org/github.com/gobuffalo/packr/v2) diff --git a/v2/SHOULDERS.md b/v2/SHOULDERS.md index dbca462..2f6f5c0 100644 --- a/v2/SHOULDERS.md +++ b/v2/SHOULDERS.md @@ -1,17 +1,23 @@ -# github.com/gobuffalo/packr/v2 Stands on the Shoulders of Giants +# /Users/smichalak/dev/packr/v2 Stands on the Shoulders of Giants -github.com/gobuffalo/packr/v2 does not try to reinvent the wheel! Instead, it uses the already great wheels developed by the Go community and puts them all together in the best way possible. Without these giants, this project would not be possible. Please make sure to check them out and thank them for all of their hard work. +/Users/smichalak/dev/packr/v2 does not try to reinvent the wheel! Instead, it uses the already great wheels developed by the Go community and puts them all together in the best way possible. Without these giants, this project would not be possible. Please make sure to check them out and thank them for all of their hard work. Thank you to the following **GIANTS**: - -* [github.com/gobuffalo/envy](https://godoc.org/github.com/gobuffalo/envy) * [github.com/gobuffalo/logger](https://godoc.org/github.com/gobuffalo/logger) * [github.com/gobuffalo/packd](https://godoc.org/github.com/gobuffalo/packd) * [github.com/karrick/godirwalk](https://godoc.org/github.com/karrick/godirwalk) + +* [github.com/konsorten/go-windows-terminal-sequences](https://godoc.org/github.com/konsorten/go-windows-terminal-sequences) + +* [github.com/markbates/errx](https://godoc.org/github.com/markbates/errx) + +* [github.com/markbates/oncer](https://godoc.org/github.com/markbates/oncer) + +* [github.com/markbates/safe](https://godoc.org/github.com/markbates/safe) * [github.com/rogpeppe/go-internal](https://godoc.org/github.com/rogpeppe/go-internal) diff --git a/v2/_fixtures/http_test/css/main.css b/v2/_fixtures/http_test/css/main.css new file mode 100644 index 0000000..25c06d8 --- /dev/null +++ b/v2/_fixtures/http_test/css/main.css @@ -0,0 +1 @@ +Css diff --git a/v2/_fixtures/http_test/footer.html b/v2/_fixtures/http_test/footer.html new file mode 100644 index 0000000..e36f7f7 --- /dev/null +++ b/v2/_fixtures/http_test/footer.html @@ -0,0 +1 @@ +Footer diff --git a/v2/_fixtures/http_test/index.html b/v2/_fixtures/http_test/index.html new file mode 100644 index 0000000..c846c91 --- /dev/null +++ b/v2/_fixtures/http_test/index.html @@ -0,0 +1 @@ +Index diff --git a/v2/_fixtures/http_test/sub/index.html b/v2/_fixtures/http_test/sub/index.html new file mode 100644 index 0000000..a1a42b5 --- /dev/null +++ b/v2/_fixtures/http_test/sub/index.html @@ -0,0 +1 @@ +Sub diff --git a/v2/box.go b/v2/box.go index 2e37f40..a2636de 100644 --- a/v2/box.go +++ b/v2/box.go @@ -16,7 +16,7 @@ "github.com/gobuffalo/packr/v2/file" "github.com/gobuffalo/packr/v2/file/resolver" "github.com/gobuffalo/packr/v2/plog" - "github.com/gobuffalo/packr/v2/internal/takeon/github.com/markbates/oncer" + "github.com/markbates/oncer" ) var _ packd.Box = &Box{} @@ -28,12 +28,12 @@ // Box represent a folder on a disk you want to // have access to in the built Go binary. type Box struct { - Path string `json:"path"` - Name string `json:"name"` - ResolutionDir string `json:"resolution_dir"` - DefaultResolver resolver.Resolver `json:"default_resolver"` - resolvers resolversMap - dirs dirsMap + Path string `json:"path"` + Name string `json:"name"` + ResolutionDir string `json:"resolution_dir"` + DefaultResolver resolver.Resolver `json:"default_resolver"` + resolvers resolversMap + dirs dirsMap } // NewBox returns a Box that can be used to @@ -215,7 +215,12 @@ f, err := r.Resolve(b.Name, key) if err != nil { - z := filepath.Join(resolver.OsPath(b.ResolutionDir), filepath.FromSlash(path.Clean("/"+resolver.OsPath(key)))) + z, err := resolver.ResolvePathInBase(resolver.OsPath(b.ResolutionDir), filepath.FromSlash(path.Clean("/"+resolver.OsPath(key)))) + if err != nil { + plog.Debug(r, "Resolve", "box", b.Name, "key", key, "err", err) + return f, err + } + f, err = r.Resolve(b.Name, z) if err != nil { plog.Debug(r, "Resolve", "box", b.Name, "key", z, "err", err) diff --git a/v2/box_test.go b/v2/box_test.go index 5411958..75fc8c4 100644 --- a/v2/box_test.go +++ b/v2/box_test.go @@ -182,9 +182,9 @@ r := require.New(t) d := resolver.NewInMemory(map[string]file.File{ - "foo.txt": qfile("foo.txt", "foo!"), - "bar": qfile("bar", "bar!"), - "baz/index.html": qfile("baz", "baz!"), + "foo.txt": qfile("foo.txt", "foo!"), + "bar": qfile("bar", "bar!"), + "baz/index.html": qfile("baz", "baz!"), }) box := New("Test_Box_Open", "./templates") @@ -223,3 +223,31 @@ r.True(box.HasDir("c")) r.False(box.HasDir("a")) } + +func Test_Box_Traversal_Standard(t *testing.T) { + r := require.New(t) + box := New("Test_Box_Traversal_Standard", "") + _, err := box.FindString("../fixtures/hello.txt") + r.Error(err) +} + +func Test_Box_Traversal_Standard_Depth2(t *testing.T) { + r := require.New(t) + box := New("Test_Box_Traversal_Standard_Depth2", "") + _, err := box.FindString("../../packr/fixtures/hello.txt") + r.Error(err) +} + +func Test_Box_Traversal_Backslash(t *testing.T) { + r := require.New(t) + box := New("Test_Box_Traversal_Backslash", "") + _, err := box.FindString("..\\fixtures\\hello.txt") + r.Error(err) +} + +func Test_Box_Traversal_Backslash_Depth2(t *testing.T) { + r := require.New(t) + box := New("Test_Box_Traversal_Backslash_Depth2", "") + _, err := box.FindString("..\\..\\packr2\\fixtures\\hello.txt") + r.Error(err) +} diff --git a/v2/deprecated.go b/v2/deprecated.go index 25f5b34..0da2201 100644 --- a/v2/deprecated.go +++ b/v2/deprecated.go @@ -6,7 +6,7 @@ "github.com/gobuffalo/packr/v2/file" "github.com/gobuffalo/packr/v2/file/resolver" - "github.com/gobuffalo/packr/v2/internal/takeon/github.com/markbates/oncer" + "github.com/markbates/oncer" ) // File has been deprecated and file.File should be used instead diff --git a/v2/file/info.go b/v2/file/info.go index 45ae835..90acb8c 100644 --- a/v2/file/info.go +++ b/v2/file/info.go @@ -6,11 +6,11 @@ ) type info struct { - Path string - Contents []byte - size int64 - modTime time.Time - isDir bool + Path string + Contents []byte + size int64 + modTime time.Time + isDir bool } func (f info) Name() string { diff --git a/v2/file/resolver/disk.go b/v2/file/resolver/disk.go index 9afe8a0..8c3c1e7 100644 --- a/v2/file/resolver/disk.go +++ b/v2/file/resolver/disk.go @@ -23,21 +23,52 @@ } func (d *Disk) Resolve(box string, name string) (file.File, error) { + var err error path := OsPath(name) if !filepath.IsAbs(path) { - path = filepath.Join(OsPath(d.Root), path) + path, err = ResolvePathInBase(OsPath(d.Root), path) + if err != nil { + return nil, err + } } + fi, err := os.Stat(path) if err != nil { return nil, err } if fi.IsDir() { - return file.NewDir(OsPath(name)) + return nil, os.ErrNotExist } if bb, err := ioutil.ReadFile(path); err == nil { return file.NewFile(OsPath(name), bb) } return nil, os.ErrNotExist +} + +// ResolvePathInBase returns a path that is guaranteed to be inside of the base directory or an error +func ResolvePathInBase(base, path string) (string, error) { + // Determine the absolute file path of the base directory + d, err := filepath.Abs(base) + if err != nil { + return "", err + } + + // Return the base directory if no file was requested + if path == "/" || path == "\\" { + return d, nil + } + + // Resolve the absolute file path after combining the key with base + p, err := filepath.Abs(filepath.Join(d, path)) + if err != nil { + return "", err + } + + // Verify that the resolved path is inside of the base directory + if !strings.HasPrefix(p, d+string(filepath.Separator)) { + return "", os.ErrNotExist + } + return p, nil } var _ file.FileMappable = &Disk{} @@ -70,8 +101,8 @@ return nil } err := godirwalk.Walk(root, &godirwalk.Options{ - FollowSymbolicLinks: true, - Callback: callback, + FollowSymbolicLinks: true, + Callback: callback, }) if err != nil { plog.Logger.Errorf("[%s] error walking %v", root, err) diff --git a/v2/file/resolver/encoding/hex/hex.go b/v2/file/resolver/encoding/hex/hex.go index aad1f0d..f4fda4e 100644 --- a/v2/file/resolver/encoding/hex/hex.go +++ b/v2/file/resolver/encoding/hex/hex.go @@ -15,7 +15,7 @@ // EncodedLen returns the length of an encoding of n source bytes. // Specifically, it returns n * 2. -func EncodedLen(n int) int { return n * 2 } +func EncodedLen(n int) int { return n * 2 } // Encode encodes src into EncodedLen(len(src)) // bytes of dst. As a convenience, it returns the number @@ -44,7 +44,7 @@ // DecodedLen returns the length of a decoding of x source bytes. // Specifically, it returns x / 2. -func DecodedLen(x int) int { return x / 2 } +func DecodedLen(x int) int { return x / 2 } // Decode decodes src into DecodedLen(len(src)) bytes, // returning the actual number of bytes written to dst. @@ -126,9 +126,9 @@ const bufferSize = 1024 type encoder struct { - w io.Writer - err error - out [bufferSize]byte // output buffer + w io.Writer + err error + out [bufferSize]byte // output buffer } // NewEncoder returns an io.Writer that writes lowercase hexadecimal characters to w. @@ -153,10 +153,10 @@ } type decoder struct { - r io.Reader - err error - in []byte // input buffer (encoded form) - arr [bufferSize]byte // backing array for in + r io.Reader + err error + in []byte // input buffer (encoded form) + arr [bufferSize]byte // backing array for in } // NewDecoder returns an io.Reader that decodes hexadecimal characters from r. @@ -169,7 +169,7 @@ // Fill internal buffer with sufficient bytes to decode if len(d.in) < 2 && d.err == nil { var numCopy, numRead int - numCopy = copy(d.arr[:], d.in) // Copies either 0 or 1 bytes + numCopy = copy(d.arr[:], d.in) // Copies either 0 or 1 bytes numRead, d.err = d.r.Read(d.arr[numCopy:]) d.in = d.arr[:numCopy+numRead] if d.err == io.EOF && len(d.in)%2 != 0 { @@ -188,11 +188,11 @@ numDec, err := Decode(p, d.in[:len(p)*2]) d.in = d.in[2*numDec:] if err != nil { - d.in, d.err = nil, err // Decode error; discard input remainder + d.in, d.err = nil, err // Decode error; discard input remainder } if len(d.in) < 2 { - return numDec, d.err // Only expose errors when buffer fully consumed + return numDec, d.err // Only expose errors when buffer fully consumed } return numDec, nil } @@ -205,12 +205,12 @@ } type dumper struct { - w io.Writer - rightChars [18]byte - buf [14]byte - used int // number of bytes in the current line - n uint // number of bytes, total - closed bool + w io.Writer + rightChars [18]byte + buf [14]byte + used int // number of bytes in the current line + n uint // number of bytes, total + closed bool } func toChar(b byte) byte { diff --git a/v2/file/resolver/hex_gzip.go b/v2/file/resolver/hex_gzip.go index 251b2dd..b72de0e 100644 --- a/v2/file/resolver/hex_gzip.go +++ b/v2/file/resolver/hex_gzip.go @@ -18,9 +18,9 @@ var _ Resolver = &HexGzip{} type HexGzip struct { - packed map[string]string - unpacked map[string]string - moot *sync.RWMutex + packed map[string]string + unpacked map[string]string + moot *sync.RWMutex } func (hg HexGzip) String() string { @@ -77,9 +77,9 @@ } hg := &HexGzip{ - packed: files, - unpacked: map[string]string{}, - moot: &sync.RWMutex{}, + packed: files, + unpacked: map[string]string{}, + moot: &sync.RWMutex{}, } return hg, nil diff --git a/v2/file/resolver/ident_test.go b/v2/file/resolver/ident_test.go index ef0a97f..298123b 100644 --- a/v2/file/resolver/ident_test.go +++ b/v2/file/resolver/ident_test.go @@ -9,8 +9,8 @@ func Test_Ident_OsPath(t *testing.T) { table := map[string]string{ - "foo/bar/baz": "foo/bar/baz", - "foo\\bar\\baz": "foo/bar/baz", + "foo/bar/baz": "foo/bar/baz", + "foo\\bar\\baz": "foo/bar/baz", } if runtime.GOOS == "windows" { @@ -27,7 +27,7 @@ func ident_OsPath_Windows_Table() map[string]string { return map[string]string{ - "foo/bar/baz": "foo\\bar\\baz", - "foo\\bar\\baz": "foo\\bar\\baz", + "foo/bar/baz": "foo\\bar\\baz", + "foo\\bar\\baz": "foo\\bar\\baz", } } diff --git a/v2/go.mod b/v2/go.mod index 306ea55..82bf27a 100644 --- a/v2/go.mod +++ b/v2/go.mod @@ -1,16 +1,19 @@ module github.com/gobuffalo/packr/v2 -go 1.12 +go 1.13 require ( - github.com/gobuffalo/envy v1.7.0 - github.com/gobuffalo/logger v1.0.0 - github.com/gobuffalo/packd v0.3.0 - github.com/karrick/godirwalk v1.10.12 - github.com/rogpeppe/go-internal v1.3.0 + github.com/gobuffalo/logger v1.0.3 + github.com/gobuffalo/packd v1.0.0 + github.com/karrick/godirwalk v1.15.8 + github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect + github.com/markbates/errx v1.1.0 + github.com/markbates/oncer v1.0.0 + github.com/markbates/safe v1.0.1 + github.com/rogpeppe/go-internal v1.5.2 github.com/sirupsen/logrus v1.4.2 - github.com/spf13/cobra v0.0.5 - github.com/stretchr/testify v1.3.0 - golang.org/x/sync v0.0.0-20190423024810-112230192c58 - golang.org/x/tools v0.0.0-20190624180213-70d37148ca0c + github.com/spf13/cobra v0.0.6 + github.com/stretchr/testify v1.5.1 + golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e + golang.org/x/tools v0.0.0-20200308013534-11ec41452d41 ) diff --git a/v2/go.sum b/v2/go.sum index 6309043..86abdab 100644 --- a/v2/go.sum +++ b/v2/go.sum @@ -1,77 +1,180 @@ +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= +github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= +github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= +github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= +github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= -github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= -github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= +github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= +github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= +github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= 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/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= +github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/gobuffalo/envy v1.7.0 h1:GlXgaiBkmrYMHco6t4j7SacKO4XUjvh5pwXh0f4uxXU= -github.com/gobuffalo/envy v1.7.0/go.mod h1:n7DRkBerg/aorDM8kbduw5dN3oXGswK5liaSCx4T5NI= -github.com/gobuffalo/logger v1.0.0 h1:xw9Ko9EcC5iAFprrjJ6oZco9UpzS5MQ4jAwghsLHdy4= -github.com/gobuffalo/logger v1.0.0/go.mod h1:2zbswyIUa45I+c+FLXuWl9zSWEiVuthsk8ze5s8JvPs= -github.com/gobuffalo/packd v0.3.0 h1:eMwymTkA1uXsqxS0Tpoop3Lc0u3kTfiMBE6nKtQU4g4= -github.com/gobuffalo/packd v0.3.0/go.mod h1:zC7QkmNkYVGKPw4tHpBQ+ml7W/3tIebgeo1b36chA3Q= +github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= +github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= +github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/gobuffalo/logger v1.0.3 h1:YaXOTHNPCvkqqA7w05A4v0k2tCdpr+sgFlgINbQ6gqc= +github.com/gobuffalo/logger v1.0.3/go.mod h1:SoeejUwldiS7ZsyCBphOGURmWdwUFXs0J7TCjEhjKxM= +github.com/gobuffalo/packd v1.0.0 h1:6ERZvJHfe24rfFmA9OaoKBdC7+c9sydrytMg8SdFGBM= +github.com/gobuffalo/packd v1.0.0/go.mod h1:6VTc4htmJRFB7u1m/4LeMTWjFoYrUiBkU9Fdec9hrhI= +github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= +github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= +github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= +github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= +github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= -github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc= -github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= -github.com/karrick/godirwalk v1.10.12 h1:BqUm+LuJcXjGv1d2mj3gBiQyrQ57a0rYoAmhvJQ7RDU= -github.com/karrick/godirwalk v1.10.12/go.mod h1:RoGL9dQei4vP9ilrpETWE8CLOZ1kiN0LhBygSwrAsHA= +github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= +github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= +github.com/karrick/godirwalk v1.15.8 h1:7+rWAZPn9zuRxaIqqT8Ohs2Q2Ac0msBqwRdxNCr2VVs= +github.com/karrick/godirwalk v1.15.8/go.mod h1:j4mkqPuvaLI8mp1DroR3P6ad7cyYd4c1qeJ3RV7ULlk= +github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.2 h1:DB17ag19krx9CFsz4o3enTrPXyIXCl+2iCXH/aMAp9s= github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= +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= +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/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= +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/oncer v1.0.0 h1:E83IaVAHygyndzPimgUYJjbshhDTALZyXxvk9FOlQRY= +github.com/markbates/oncer v1.0.0/go.mod h1:Z59JA581E9GP6w96jai+TGqafHPW+cPfRxz2aSZ0mcI= +github.com/markbates/safe v1.0.1 h1:yjZkbvRM6IzKj9tlu/zMJLS0n/V351OZWRnF3QfaUxI= +github.com/markbates/safe v1.0.1/go.mod h1:nAqgmRi7cY2nqMc92/bSEeQA+R4OheNU2T1kNSCBdG0= +github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= +github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 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/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/rogpeppe/go-internal v1.3.0 h1:RR9dF3JtopPvtkroDZuVD7qquD0bnHlKSqaQhgwt8yk= -github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= +github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= +github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso= +github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= +github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= +github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= +github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= +github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= +github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= +github.com/rogpeppe/go-internal v1.5.2 h1:qLvObTrvO/XRCqmkKxUlOBc48bI3efyDuAZe25QiF0w= +github.com/rogpeppe/go-internal v1.5.2/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= +github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= +github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= +github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= +github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= -github.com/spf13/cobra v0.0.5 h1:f0B+LkLX6DtmRH1isoNA9VTtNUK9K8xYd28JNNfOv/s= -github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= +github.com/spf13/cobra v0.0.6 h1:breEStsVwemnKh2/s6gMvSdMEkwW0sK8vGStnlVBMCs= +github.com/spf13/cobra v0.0.6/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE= github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= -github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= +github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= +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.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= +github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= +github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= -golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= +go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= +go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= +go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= +golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190621222207-cc06ce4a13d4 h1:ydJNl0ENAG67pFbB+9tfhiL2pYqLhfoaZFw/cjLhY4A= -golang.org/x/crypto v0.0.0-20190621222207-cc06ce4a13d4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20191122220453-ac88ee75c92c h1:/nJuwDLoL/zrqY6gf57vxC+Pi+pZ8bfhpPkicO5H7W4= +golang.org/x/crypto v0.0.0-20191122220453-ac88ee75c92c/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU= +golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859 h1:R/3boaszxrf1GEUWTVDzSKVwLmSJpwZ1yqXm8j0v2QI= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e h1:vcxGaoTs7kV8m5Np9uUNQin4BrLOthgV7252N8V+FwY= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190422165155-953cdadca894 h1:Cz4ceDQGXuKRnVBDTS23GTn/pU5OE2C0WrNTOYK1Uuc= golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190515120540-06a5c4944438 h1:khxRGsvPk4n2y8I/mLLjp7e5dMTJmH75wvqS6nMwUtY= -golang.org/x/sys v0.0.0-20190515120540-06a5c4944438/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/tools v0.0.0-20190624180213-70d37148ca0c h1:KfpJVdWhuRqNk4XVXzjXf2KAV4TBEP77SYdFGjeGuIE= -golang.org/x/tools v0.0.0-20190624180213-70d37148ca0c/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20200308013534-11ec41452d41 h1:9Di9iYgOt9ThCipBxChBVhgNipDoE5mxO84rQV7D0FE= +golang.org/x/tools v0.0.0-20200308013534-11ec41452d41/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= +gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= +gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/v2/helpers.go b/v2/helpers.go index 072afcb..70dd07a 100644 --- a/v2/helpers.go +++ b/v2/helpers.go @@ -6,17 +6,16 @@ "runtime" "strings" - "github.com/gobuffalo/envy" "github.com/gobuffalo/packr/v2/plog" ) func construct(name string, path string) *Box { return &Box{ - Path: path, - Name: name, - ResolutionDir: resolutionDir(path), - resolvers: resolversMap{}, - dirs: dirsMap{}, + Path: path, + Name: name, + ResolutionDir: resolutionDir(path), + resolvers: resolversMap{}, + dirs: dirsMap{}, } } @@ -31,7 +30,7 @@ return ng, true } - ng = filepath.Join(envy.GoPath(), "src", ng) + ng = filepath.Join(os.Getenv("GOPATH"), "src", ng) if resolutionDirExists(ng, og) { return ng, true } diff --git a/v2/http_box_test.go b/v2/http_box_test.go index 17296ab..3685133 100644 --- a/v2/http_box_test.go +++ b/v2/http_box_test.go @@ -25,8 +25,8 @@ } hg, err := resolver.NewHexGzip(map[string]string{ - "index.html": ind, - "hello.txt": hello, + "index.html": ind, + "hello.txt": hello, }) if err != nil { panic(err) @@ -129,3 +129,41 @@ }) } } + +func Test_HTTPBox_Disk(t *testing.T) { + r := require.New(t) + + box := New("http disk box", "./_fixtures/http_test") + mux := http.NewServeMux() + mux.Handle("/", http.FileServer(box)) + + type testcase struct { + URL, Content, Location string + Code int + } + + testcases := []testcase{ + {"/", "Index", "", 200}, + {"/sub", "Sub", "", 200}, + {"/index.html", "", "./", 301}, + {"/sub/index.html", "", "./", 301}, + {"/sub/", "", "../sub", 301}, + {"/footer.html", "Footer", "", 200}, + {"/css/main.css", "Css", "", 200}, + {"/css", "404 page not found", "", 404}, + {"/css/", "404 page not found", "", 404}, + } + + for _, tc := range testcases { + t.Run("path"+tc.URL, func(t *testing.T) { + req, err := http.NewRequest("GET", tc.URL, nil) + r.NoError(err) + res := httptest.NewRecorder() + mux.ServeHTTP(res, req) + + r.Equal(tc.Code, res.Code) + r.Equal(tc.Location, res.Header().Get("location")) + r.Equal(tc.Content, strings.TrimSpace(res.Body.String())) + }) + } +} diff --git a/v2/internal/envy.go b/v2/internal/envy.go new file mode 100644 index 0000000..30cf7b5 --- /dev/null +++ b/v2/internal/envy.go @@ -0,0 +1,37 @@ +package internal + +import ( + "os" + "runtime" + "strings" +) + +// Mods returns true when go modules supports is enabled +func Mods() bool { + go111 := os.Getenv("GO111MODULE") + + if !inGoPath() { + return go111 != "off" + } + + return go111 == "on" +} + +func inGoPath() bool { + pwd, _ := os.Getwd() + for _, p := range GoPaths() { + if strings.HasPrefix(pwd, p) { + return true + } + } + return false +} + +// GoPaths return the defined gopath list. +func GoPaths() []string { + gp := os.Getenv("GOPATH") + if runtime.GOOS == "windows" { + return strings.Split(gp, ";") // Windows uses a different separator + } + return strings.Split(gp, ":") +} diff --git a/v2/internal/takeon/github.com/markbates/errx/.gitignore b/v2/internal/takeon/github.com/markbates/errx/.gitignore deleted file mode 100644 index 3689718..0000000 --- a/v2/internal/takeon/github.com/markbates/errx/.gitignore +++ /dev/null @@ -1,29 +0,0 @@ -*.log -.DS_Store -doc -tmp -pkg -*.gem -*.pid -coverage -coverage.data -build/* -*.pbxuser -*.mode1v3 -.svn -profile -.console_history -.sass-cache/* -.rake_tasks~ -*.log.lck -solr/ -.jhw-cache/ -jhw.* -*.sublime* -node_modules/ -dist/ -generated/ -.vendor/ -bin/* -gin-bin -.idea/ diff --git a/v2/internal/takeon/github.com/markbates/errx/LICENSE b/v2/internal/takeon/github.com/markbates/errx/LICENSE deleted file mode 100644 index 649efd4..0000000 --- a/v2/internal/takeon/github.com/markbates/errx/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2019 Mark Bates - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/v2/internal/takeon/github.com/markbates/errx/Makefile b/v2/internal/takeon/github.com/markbates/errx/Makefile deleted file mode 100644 index 0ac539f..0000000 --- a/v2/internal/takeon/github.com/markbates/errx/Makefile +++ /dev/null @@ -1,61 +0,0 @@ -TAGS ?= "" -GO_BIN ?= "go" - -install: - $(GO_BIN) install -tags ${TAGS} -v . - make tidy - -tidy: -ifeq ($(GO111MODULE),on) - $(GO_BIN) mod tidy -else - echo skipping go mod tidy -endif - -deps: - $(GO_BIN) get -tags ${TAGS} -t ./... - make tidy - -build: - $(GO_BIN) build -v . - make tidy - -test: - $(GO_BIN) test -cover -tags ${TAGS} ./... - make tidy - -ci-deps: - $(GO_BIN) get -tags ${TAGS} -t ./... - -ci-test: - $(GO_BIN) test -tags ${TAGS} -race ./... - -lint: - go get github.com/golangci/golangci-lint/cmd/golangci-lint - golangci-lint run --enable-all - make tidy - -update: -ifeq ($(GO111MODULE),on) - rm go.* - $(GO_BIN) mod init - $(GO_BIN) mod tidy -else - $(GO_BIN) get -u -tags ${TAGS} -endif - make test - make install - make tidy - -release-test: - $(GO_BIN) test -tags ${TAGS} -race ./... - make tidy - -release: - $(GO_BIN) get github.com/gobuffalo/release - make tidy - release -y -f version.go --skip-packr - make tidy - - - diff --git a/v2/internal/takeon/github.com/markbates/errx/SHOULDERS.md b/v2/internal/takeon/github.com/markbates/errx/SHOULDERS.md deleted file mode 100644 index b19072e..0000000 --- a/v2/internal/takeon/github.com/markbates/errx/SHOULDERS.md +++ /dev/null @@ -1,6 +0,0 @@ -# github.com/markbates/errx Stands on the Shoulders of Giants - -github.com/markbates/errx does not try to reinvent the wheel! Instead, it uses the already great wheels developed by the Go community and puts them all together in the best way possible. Without these giants, this project would not be possible. Please make sure to check them out and thank them for all of their hard work. - -Thank you to the following **GIANTS**: - diff --git a/v2/internal/takeon/github.com/markbates/errx/azure-pipelines.yml b/v2/internal/takeon/github.com/markbates/errx/azure-pipelines.yml deleted file mode 100644 index 417e2c5..0000000 --- a/v2/internal/takeon/github.com/markbates/errx/azure-pipelines.yml +++ /dev/null @@ -1,71 +0,0 @@ -variables: - GOBIN: "$(GOPATH)/bin" # Go binaries path - GOPATH: "$(system.defaultWorkingDirectory)/gopath" # Go workspace path - modulePath: "$(GOPATH)/src/github.com/$(build.repository.name)" # Path to the module"s code - -jobs: -- job: Windows - pool: - vmImage: "vs2017-win2016" - strategy: - matrix: - go 1.10: - go_version: "1.10" - go 1.11 (on): - go_version: "1.11.5" - GO111MODULE: "on" - go 1.11 (off): - go_version: "1.11.5" - GO111MODULE: "off" - go 1.12 (on): - go_version: "1.12" - GO111MODULE: "on" - go 1.12 (off): - go_version: "1.12" - GO111MODULE: "off" - steps: - - template: azure-tests.yml - -- job: macOS - pool: - vmImage: "macOS-10.13" - strategy: - matrix: - go 1.10: - go_version: "1.10" - go 1.11 (on): - go_version: "1.11.5" - GO111MODULE: "on" - go 1.11 (off): - go_version: "1.11.5" - GO111MODULE: "off" - go 1.12 (on): - go_version: "1.12" - GO111MODULE: "on" - go 1.12 (off): - go_version: "1.12" - GO111MODULE: "off" - steps: - - template: azure-tests.yml - -- job: Linux - pool: - vmImage: "ubuntu-16.04" - strategy: - matrix: - go 1.10: - go_version: "1.10" - go 1.11 (on): - go_version: "1.11.5" - GO111MODULE: "on" - go 1.11 (off): - go_version: "1.11.5" - GO111MODULE: "off" - go 1.12 (on): - go_version: "1.12" - GO111MODULE: "on" - go 1.12 (off): - go_version: "1.12" - GO111MODULE: "off" - steps: - - template: azure-tests.yml diff --git a/v2/internal/takeon/github.com/markbates/errx/azure-tests.yml b/v2/internal/takeon/github.com/markbates/errx/azure-tests.yml deleted file mode 100644 index eea5822..0000000 --- a/v2/internal/takeon/github.com/markbates/errx/azure-tests.yml +++ /dev/null @@ -1,19 +0,0 @@ -steps: - - task: GoTool@0 - inputs: - version: $(go_version) - - task: Bash@3 - inputs: - targetType: inline - script: | - mkdir -p "$(GOBIN)" - mkdir -p "$(GOPATH)/pkg" - mkdir -p "$(modulePath)" - shopt -s extglob - mv !(gopath) "$(modulePath)" - displayName: "Setup Go Workspace" - - script: | - go get -t -v ./... - go test -race ./... - workingDirectory: "$(modulePath)" - displayName: "Tests" diff --git a/v2/internal/takeon/github.com/markbates/errx/errx.go b/v2/internal/takeon/github.com/markbates/errx/errx.go deleted file mode 100644 index 5a6f639..0000000 --- a/v2/internal/takeon/github.com/markbates/errx/errx.go +++ /dev/null @@ -1,23 +0,0 @@ -package errx - -// go2 errors -type Wrapper interface { - Unwrap() error -} - -// pkg/errors -type Causer interface { - Cause() error -} - -func Unwrap(err error) error { - switch e := err.(type) { - case Wrapper: - return e.Unwrap() - case Causer: - return e.Cause() - } - return err -} - -var Cause = Unwrap diff --git a/v2/internal/takeon/github.com/markbates/errx/version.go b/v2/internal/takeon/github.com/markbates/errx/version.go deleted file mode 100644 index 82e25a1..0000000 --- a/v2/internal/takeon/github.com/markbates/errx/version.go +++ /dev/null @@ -1,4 +0,0 @@ -package errx - -// Version of errx -const Version = "v1.0.0" diff --git a/v2/internal/takeon/github.com/markbates/oncer/.gitignore b/v2/internal/takeon/github.com/markbates/oncer/.gitignore deleted file mode 100644 index 3689718..0000000 --- a/v2/internal/takeon/github.com/markbates/oncer/.gitignore +++ /dev/null @@ -1,29 +0,0 @@ -*.log -.DS_Store -doc -tmp -pkg -*.gem -*.pid -coverage -coverage.data -build/* -*.pbxuser -*.mode1v3 -.svn -profile -.console_history -.sass-cache/* -.rake_tasks~ -*.log.lck -solr/ -.jhw-cache/ -jhw.* -*.sublime* -node_modules/ -dist/ -generated/ -.vendor/ -bin/* -gin-bin -.idea/ diff --git a/v2/internal/takeon/github.com/markbates/oncer/LICENSE b/v2/internal/takeon/github.com/markbates/oncer/LICENSE deleted file mode 100644 index a538bcb..0000000 --- a/v2/internal/takeon/github.com/markbates/oncer/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2018 Mark Bates - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/v2/internal/takeon/github.com/markbates/oncer/Makefile b/v2/internal/takeon/github.com/markbates/oncer/Makefile deleted file mode 100644 index 187cb8a..0000000 --- a/v2/internal/takeon/github.com/markbates/oncer/Makefile +++ /dev/null @@ -1,40 +0,0 @@ -TAGS ?= "sqlite" -GO_BIN ?= go - -install: - packr - $(GO_BIN) install -v . - -deps: - $(GO_BIN) get github.com/gobuffalo/release - $(GO_BIN) get github.com/gobuffalo/packr/packr - $(GO_BIN) get -tags ${TAGS} -t ./... - $(GO_BIN) mod tidy - -build: - packr - $(GO_BIN) build -v . - -test: - packr - $(GO_BIN) test -tags ${TAGS} ./... - -ci-test: deps - $(GO_BIN) test -tags ${TAGS} -race ./... - -lint: - gometalinter --vendor ./... --deadline=1m --skip=internal - -update: - $(GO_BIN) get -u -tags ${TAGS} - $(GO_BIN) mod tidy - packr - make test - make install - $(GO_BIN) mod tidy - -release-test: - $(GO_BIN) test -tags ${TAGS} -race ./... - -release: - release -y -f version.go diff --git a/v2/internal/takeon/github.com/markbates/oncer/deprecate.go b/v2/internal/takeon/github.com/markbates/oncer/deprecate.go deleted file mode 100644 index 4eb3a44..0000000 --- a/v2/internal/takeon/github.com/markbates/oncer/deprecate.go +++ /dev/null @@ -1,20 +0,0 @@ -package oncer - -import ( - "fmt" - "io" - "os" -) - -const deprecated = "DEPRECATED" - -var deprecationWriter io.Writer = os.Stdout - -func Deprecate(depth int, name string, msg string) { - Do(deprecated+name, func() { - fmt.Fprintf(deprecationWriter, "[%s] %s has been deprecated.\n", deprecated, name) - if len(msg) > 0 { - fmt.Fprintf(deprecationWriter, "\t%s\n", msg) - } - }) -} diff --git a/v2/internal/takeon/github.com/markbates/oncer/log.go b/v2/internal/takeon/github.com/markbates/oncer/log.go deleted file mode 100644 index ed43463..0000000 --- a/v2/internal/takeon/github.com/markbates/oncer/log.go +++ /dev/null @@ -1,7 +0,0 @@ -//+build !debug - -package oncer - -func log(name string, fn func()) func() { - return fn -} diff --git a/v2/internal/takeon/github.com/markbates/oncer/log_debug.go b/v2/internal/takeon/github.com/markbates/oncer/log_debug.go deleted file mode 100644 index 76d0e11..0000000 --- a/v2/internal/takeon/github.com/markbates/oncer/log_debug.go +++ /dev/null @@ -1,19 +0,0 @@ -//+build debug - -package oncer - -import ( - "fmt" - "time" -) - -func log(name string, fn func()) func() { - return func() { - start := time.Now() - if len(name) > 80 { - name = name[(len(name) - 80):] - } - defer fmt.Println(name, time.Now().Sub(start)) - fn() - } -} diff --git a/v2/internal/takeon/github.com/markbates/oncer/oncer.go b/v2/internal/takeon/github.com/markbates/oncer/oncer.go deleted file mode 100644 index 5b3ab8d..0000000 --- a/v2/internal/takeon/github.com/markbates/oncer/oncer.go +++ /dev/null @@ -1,26 +0,0 @@ -package oncer - -import ( - "sync" -) - -var onces = &sync.Map{} - -func Do(name string, fn func()) { - o, _ := onces.LoadOrStore(name, &sync.Once{}) - if once, ok := o.(*sync.Once); ok { - once.Do(log(name, fn)) - } -} - -func Reset(names ...string) { - if len(names) == 0 { - onces = &sync.Map{} - return - } - - for _, n := range names { - onces.Delete(n) - onces.Delete(deprecated + n) - } -} diff --git a/v2/internal/takeon/github.com/markbates/safe/.gitignore b/v2/internal/takeon/github.com/markbates/safe/.gitignore deleted file mode 100644 index 3689718..0000000 --- a/v2/internal/takeon/github.com/markbates/safe/.gitignore +++ /dev/null @@ -1,29 +0,0 @@ -*.log -.DS_Store -doc -tmp -pkg -*.gem -*.pid -coverage -coverage.data -build/* -*.pbxuser -*.mode1v3 -.svn -profile -.console_history -.sass-cache/* -.rake_tasks~ -*.log.lck -solr/ -.jhw-cache/ -jhw.* -*.sublime* -node_modules/ -dist/ -generated/ -.vendor/ -bin/* -gin-bin -.idea/ diff --git a/v2/internal/takeon/github.com/markbates/safe/.gometalinter.json b/v2/internal/takeon/github.com/markbates/safe/.gometalinter.json deleted file mode 100644 index e4f65a3..0000000 --- a/v2/internal/takeon/github.com/markbates/safe/.gometalinter.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "Enable": ["vet", "golint", "goimports", "deadcode", "gotype", "ineffassign", "misspell", "nakedret", "unconvert", "megacheck", "varcheck"] -} diff --git a/v2/internal/takeon/github.com/markbates/safe/.travis.yml b/v2/internal/takeon/github.com/markbates/safe/.travis.yml deleted file mode 100644 index cf1d2c7..0000000 --- a/v2/internal/takeon/github.com/markbates/safe/.travis.yml +++ /dev/null @@ -1,26 +0,0 @@ -language: go - -sudo: false - -matrix: - include: - - go: "1.9.x" - - go: "1.10.x" - - go: "1.11.x" - env: - - GO111MODULE=off - - go: "1.11.x" - env: - - GO111MODULE=on - - go: "tip" - env: - - GO111MODULE=off - - go: "tip" - env: - - GO111MODULE=on - allow_failures: - - go: "tip" - -install: make deps - -script: make ci-test diff --git a/v2/internal/takeon/github.com/markbates/safe/LICENSE b/v2/internal/takeon/github.com/markbates/safe/LICENSE deleted file mode 100644 index a538bcb..0000000 --- a/v2/internal/takeon/github.com/markbates/safe/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2018 Mark Bates - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/v2/internal/takeon/github.com/markbates/safe/Makefile b/v2/internal/takeon/github.com/markbates/safe/Makefile deleted file mode 100644 index e0e2f3b..0000000 --- a/v2/internal/takeon/github.com/markbates/safe/Makefile +++ /dev/null @@ -1,55 +0,0 @@ -TAGS ?= "sqlite" -GO_BIN ?= go - -install: - packr - $(GO_BIN) install -tags ${TAGS} -v . - make tidy - -tidy: -ifeq ($(GO111MODULE),on) - $(GO_BIN) mod tidy -else - echo skipping go mod tidy -endif - -deps: - $(GO_BIN) get github.com/gobuffalo/release - $(GO_BIN) get github.com/gobuffalo/packr/packr - $(GO_BIN) get -tags ${TAGS} -t ./... - make tidy - -build: - packr - $(GO_BIN) build -v . - make tidy - -test: - packr - $(GO_BIN) test -tags ${TAGS} ./... - make tidy - -ci-test: - $(GO_BIN) test -tags ${TAGS} -race ./... - make tidy - -lint: - gometalinter --vendor ./... --deadline=1m --skip=internal - make tidy - -update: - $(GO_BIN) get -u -tags ${TAGS} - make tidy - packr - make test - make install - make tidy - -release-test: - $(GO_BIN) test -tags ${TAGS} -race ./... - make tidy - -release: - make tidy - release -y -f version.go - make tidy diff --git a/v2/internal/takeon/github.com/markbates/safe/safe.go b/v2/internal/takeon/github.com/markbates/safe/safe.go deleted file mode 100644 index a40d208..0000000 --- a/v2/internal/takeon/github.com/markbates/safe/safe.go +++ /dev/null @@ -1,33 +0,0 @@ -package safe - -import ( - "errors" - "fmt" -) - -// Run the function safely knowing that if it panics -// the panic will be caught and returned as an error -func Run(fn func()) (err error) { - return RunE(func() error { - fn() - return nil - }) -} - -// Run the function safely knowing that if it panics -// the panic will be caught and returned as an error -func RunE(fn func() error) (err error) { - defer func() { - if err != nil { - return - } - if ex := recover(); ex != nil { - if e, ok := ex.(error); ok { - err = e - return - } - err = errors.New(fmt.Sprint(ex)) - } - }() - return fn() -} diff --git a/v2/internal/takeon/github.com/markbates/safe/shoulders.md b/v2/internal/takeon/github.com/markbates/safe/shoulders.md deleted file mode 100644 index a3821f2..0000000 --- a/v2/internal/takeon/github.com/markbates/safe/shoulders.md +++ /dev/null @@ -1,8 +0,0 @@ -# github.com/markbates/safe Stands on the Shoulders of Giants - -github.com/markbates/safe does not try to reinvent the wheel! Instead, it uses the already great wheels developed by the Go community and puts them all together in the best way possible. Without these giants this project would not be possible. Please make sure to check them out and thank them for all of their hard work. - -Thank you to the following **GIANTS**: - - -* [github.com/markbates/safe](https://godoc.org/github.com/markbates/safe) diff --git a/v2/internal/takeon/github.com/markbates/safe/version.go b/v2/internal/takeon/github.com/markbates/safe/version.go deleted file mode 100644 index e655dc5..0000000 --- a/v2/internal/takeon/github.com/markbates/safe/version.go +++ /dev/null @@ -1,3 +0,0 @@ -package safe - -const Version = "v1.0.1" diff --git a/v2/jam/pack.go b/v2/jam/pack.go index 71191a5..d38c8e7 100644 --- a/v2/jam/pack.go +++ b/v2/jam/pack.go @@ -15,11 +15,11 @@ // PackOptions ... type PackOptions struct { - IgnoreImports bool - Legacy bool - StoreCmd string - Roots []string - RootsOptions *parser.RootsOptions + IgnoreImports bool + Legacy bool + StoreCmd string + Roots []string + RootsOptions *parser.RootsOptions } // Pack the roots given + PWD diff --git a/v2/jam/parser/box.go b/v2/jam/parser/box.go index 1e64a58..b294191 100644 --- a/v2/jam/parser/box.go +++ b/v2/jam/parser/box.go @@ -8,12 +8,12 @@ // Box found while parsing a file type Box struct { - Name string // name of the box - Path string // relative path of folder NewBox("./templates") - AbsPath string // absolute path of Path - Package string // the package name the box was found in - PWD string // the PWD when the parser was run - PackageDir string // the absolute path of the package where the box was found + Name string // name of the box + Path string // relative path of folder NewBox("./templates") + AbsPath string // absolute path of Path + Package string // the package name the box was found in + PWD string // the PWD when the parser was run + PackageDir string // the absolute path of the package where the box was found } type Boxes []*Box @@ -32,9 +32,9 @@ name = strings.Replace(name, "\"", "", -1) pwd, _ := os.Getwd() box := &Box{ - Name: name, - Path: path, - PWD: pwd, + Name: name, + Path: path, + PWD: pwd, } return box } diff --git a/v2/jam/parser/file.go b/v2/jam/parser/file.go index 742da48..3bf49cd 100644 --- a/v2/jam/parser/file.go +++ b/v2/jam/parser/file.go @@ -10,8 +10,8 @@ // File that is to be parsed type File struct { io.Reader - Path string - AbsPath string + Path string + AbsPath string } // Name of the file "app.go" @@ -47,8 +47,8 @@ abs, _ = filepath.Abs(path) } return &File{ - Reader: r, - Path: path, - AbsPath: abs, + Reader: r, + Path: path, + AbsPath: abs, } } diff --git a/v2/jam/parser/finder.go b/v2/jam/parser/finder.go index db194dd..2ad808e 100644 --- a/v2/jam/parser/finder.go +++ b/v2/jam/parser/finder.go @@ -3,14 +3,15 @@ import ( "fmt" "go/build" + "os" "path/filepath" "strings" "time" "github.com/gobuffalo/packr/v2/plog" "github.com/karrick/godirwalk" - "github.com/gobuffalo/packr/v2/internal/takeon/github.com/markbates/errx" - "github.com/gobuffalo/packr/v2/internal/takeon/github.com/markbates/oncer" + "github.com/markbates/errx" + "github.com/markbates/oncer" ) type finder struct { @@ -33,12 +34,22 @@ if ext != ".go" { return nil } + //check if path is a dir + fi, err := os.Stat(path) + if err != nil { + return nil + } + + if fi.IsDir() { + return nil + } + names = append(names, path) return nil } err = godirwalk.Walk(dir, &godirwalk.Options{ - FollowSymbolicLinks: true, - Callback: callback, + FollowSymbolicLinks: true, + Callback: callback, }) }) diff --git a/v2/jam/parser/gogen.go b/v2/jam/parser/gogen.go index e579645..5ba95de 100644 --- a/v2/jam/parser/gogen.go +++ b/v2/jam/parser/gogen.go @@ -8,22 +8,22 @@ "strings" "github.com/gobuffalo/packd" - "github.com/gobuffalo/packr/v2/internal/takeon/github.com/markbates/errx" + "github.com/markbates/errx" ) // ParsedFile ... type ParsedFile struct { - File packd.SimpleFile - FileSet *token.FileSet - Ast *ast.File - Lines []string + File packd.SimpleFile + FileSet *token.FileSet + Ast *ast.File + Lines []string } // ParseFileMode ... func ParseFileMode(gf packd.SimpleFile, mode parser.Mode) (ParsedFile, error) { pf := ParsedFile{ - FileSet: token.NewFileSet(), - File: gf, + FileSet: token.NewFileSet(), + File: gf, } src := gf.String() diff --git a/v2/jam/parser/parser.go b/v2/jam/parser/parser.go index eb1af75..fd5681d 100644 --- a/v2/jam/parser/parser.go +++ b/v2/jam/parser/parser.go @@ -10,8 +10,8 @@ // Parser to find boxes type Parser struct { - Prospects []*File // a list of files to check for boxes - IgnoreImports bool + Prospects []*File // a list of files to check for boxes + IgnoreImports bool } // Run the parser and run any boxes found diff --git a/v2/jam/parser/parser_test.go b/v2/jam/parser/parser_test.go index 217fcc2..2a04411 100644 --- a/v2/jam/parser/parser_test.go +++ b/v2/jam/parser/parser_test.go @@ -7,7 +7,7 @@ "github.com/gobuffalo/packr/v2/jam/parser" "github.com/gobuffalo/packr/v2/jam/store" - "github.com/gobuffalo/packr/v2/internal/takeon/github.com/markbates/oncer" + "github.com/markbates/oncer" "github.com/stretchr/testify/require" ) diff --git a/v2/jam/parser/prospect_test.go b/v2/jam/parser/prospect_test.go index e3f6233..f023f81 100644 --- a/v2/jam/parser/prospect_test.go +++ b/v2/jam/parser/prospect_test.go @@ -8,8 +8,8 @@ func Test_IsProspect(t *testing.T) { table := []struct { - path string - pass bool + path string + pass bool }{ {"foo/.git/config", false}, {"foo/.git/baz.go", false}, diff --git a/v2/jam/parser/roots.go b/v2/jam/parser/roots.go index ad4e09f..a550182 100644 --- a/v2/jam/parser/roots.go +++ b/v2/jam/parser/roots.go @@ -13,8 +13,8 @@ ) type RootsOptions struct { - IgnoreImports bool - Ignores []string + IgnoreImports bool + Ignores []string } func (r RootsOptions) String() string { @@ -49,8 +49,8 @@ return nil } wopts := &godirwalk.Options{ - FollowSymbolicLinks: true, - Callback: callback, + FollowSymbolicLinks: true, + Callback: callback, } for _, root := range roots { plog.Debug(p, "NewFromRoots", "walking", root) diff --git a/v2/jam/parser/visitor.go b/v2/jam/parser/visitor.go index bc96244..d41ac49 100644 --- a/v2/jam/parser/visitor.go +++ b/v2/jam/parser/visitor.go @@ -12,17 +12,17 @@ ) type Visitor struct { - File packd.SimpleFile - Package string - boxes map[string]*Box - errors []error + File packd.SimpleFile + Package string + boxes map[string]*Box + errors []error } func NewVisitor(f *File) *Visitor { return &Visitor{ - File: f, - boxes: map[string]*Box{}, - errors: []error{}, + File: f, + boxes: map[string]*Box{}, + errors: []error{}, } } diff --git a/v2/jam/store/_fixtures/disk-pack/go.mod b/v2/jam/store/_fixtures/disk-pack/go.mod index 287ee37..81dcffb 100644 --- a/v2/jam/store/_fixtures/disk-pack/go.mod +++ b/v2/jam/store/_fixtures/disk-pack/go.mod @@ -1,4 +1,6 @@ module foo + +go 1.14 require ( github.com/gobuffalo/packr/v2 v2.0.0-rc.2 // indirect diff --git a/v2/jam/store/_fixtures/disk-pack/go.sum b/v2/jam/store/_fixtures/disk-pack/go.sum index f7efc3c..41e756e 100644 --- a/v2/jam/store/_fixtures/disk-pack/go.sum +++ b/v2/jam/store/_fixtures/disk-pack/go.sum @@ -1,3 +1,5 @@ +errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw= +errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/Masterminds/semver v1.4.2/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y= @@ -191,8 +193,7 @@ github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= github.com/onsi/gomega v1.4.2/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= -errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw= -errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= github.com/serenize/snaker v0.0.0-20171204205717-a683aaf2d516/go.mod h1:Yow6lPLSAXx2ifx470yD/nUe22Dv5vBvxK/UK9UUTVs= diff --git a/v2/jam/store/disk.go b/v2/jam/store/disk.go index 50ac912..9a46876 100644 --- a/v2/jam/store/disk.go +++ b/v2/jam/store/disk.go @@ -17,13 +17,14 @@ "strings" "sync" - "github.com/gobuffalo/envy" + "github.com/gobuffalo/packr/v2/internal" + "github.com/karrick/godirwalk" + "github.com/gobuffalo/packr/v2/file/resolver/encoding/hex" "github.com/gobuffalo/packr/v2/plog" "github.com/rogpeppe/go-internal/modfile" "github.com/gobuffalo/packr/v2/jam/parser" - "github.com/karrick/godirwalk" "golang.org/x/sync/errgroup" ) @@ -32,11 +33,11 @@ const DISK_GLOBAL_KEY = "__packr_global__" type Disk struct { - DBPath string - DBPackage string - global map[string]string - boxes map[string]*parser.Box - moot *sync.RWMutex + DBPath string + DBPackage string + global map[string]string + boxes map[string]*parser.Box + moot *sync.RWMutex } func NewDisk(path string, pkg string) *Disk { @@ -50,11 +51,11 @@ path, _ = filepath.Abs(path) } return &Disk{ - DBPath: path, - DBPackage: pkg, - global: map[string]string{}, - boxes: map[string]*parser.Box{}, - moot: &sync.RWMutex{}, + DBPath: path, + DBPackage: pkg, + global: map[string]string{}, + boxes: map[string]*parser.Box{}, + moot: &sync.RWMutex{}, } } @@ -68,7 +69,7 @@ return names, nil } err := godirwalk.Walk(path, &godirwalk.Options{ - FollowSymbolicLinks: true, + FollowSymbolicLinks: true, Callback: func(path string, de *godirwalk.Dirent) error { if !de.IsRegular() { return nil @@ -126,15 +127,15 @@ } type options struct { - Package string - GlobalFiles map[string]string - Boxes []optsBox - GK string + Package string + GlobalFiles map[string]string + Boxes []optsBox + GK string } type optsBox struct { - Name string - Path string + Name string + Path string } // Close ... @@ -145,9 +146,9 @@ xb := &parser.Box{Name: DISK_GLOBAL_KEY} opts := options{ - Package: d.DBPackage, - GlobalFiles: map[string]string{}, - GK: makeKey(xb, d.DBPath), + Package: d.DBPackage, + GlobalFiles: map[string]string{}, + GK: makeKey(xb, d.DBPath), } wg := errgroup.Group{} @@ -204,8 +205,8 @@ } type file struct { - Resolver string - ForwardPath string + Resolver string + ForwardPath string } tmpl, err := template.New("box.go").Parse(diskGlobalBoxTmpl) @@ -218,13 +219,13 @@ p := strings.TrimPrefix(s, box.AbsPath) p = strings.TrimPrefix(p, string(filepath.Separator)) files = append(files, file{ - Resolver: strings.Replace(p, "\\", "/", -1), - ForwardPath: makeKey(box, s), + Resolver: strings.Replace(p, "\\", "/", -1), + ForwardPath: makeKey(box, s), }) } opts := map[string]interface{}{ - "Box": box, - "Files": files, + "Box": box, + "Files": files, } bb := &bytes.Buffer{} @@ -254,7 +255,7 @@ } var ip string - if envy.Mods() { + if internal.Mods() { // Starting in 1.12, we can rely on Go's method for // resolving where go.mod resides. Prior versions will // simply return an empty string. @@ -285,7 +286,7 @@ ip = strings.Replace(ip, "\\", "/", -1) } else { ip = filepath.Dir(d.DBPath) - srcs := envy.GoPaths() + srcs := internal.GoPaths() srcs = append(srcs, build.Default.SrcDirs()...) for _, x := range srcs { ip = strings.TrimPrefix(ip, "/private") @@ -312,11 +313,11 @@ defer f.Close() o := struct { - Package string - Import string + Package string + Import string }{ - Package: b.Package, - Import: ip, + Package: b.Package, + Import: ip, } tmpl, err := template.New(p).Parse(diskImportTmpl) diff --git a/v2/jam/store/disk_packed_test.go b/v2/jam/store/disk_packed_test.go index 67f8a34..08b0c41 100644 --- a/v2/jam/store/disk_packed_test.go +++ b/v2/jam/store/disk_packed_test.go @@ -10,11 +10,11 @@ g := packr.New(gk, "") hgr, err := resolver.NewHexGzip(map[string]string{ - "4abf3a9b652ecec6b347eb6acb7ce363": "1f8b08000000000000fff2750c72775508cecc2d28cecfe302040000fffffb1d273b0e000000", - "5cfc8f95f98237a10affc14a76e3e20b": "1f8b08000000000000fff2757477f7745508cecc2d28cecfe302040000ffffb09167470f000000", - "6d8be986fa35821e7e869fbb118e51ba": "1f8b08000000000000fff2f0f7750d5208cecc2d28cecfe302040000fffffb2ef0a60e000000", - "99e5497ae5f5988fafafbcd15ed74d22": "1f8b08000000000000fff2f10c765408cecc2d28cecfe302040000ffffab9bc93e0d000000", - "bb006aa6261a80f6c52c640f713659c1": "1f8b08000000000000ff72720c0a5108cecc2d28cecfe302040000ffff89742ac20d000000", + "4abf3a9b652ecec6b347eb6acb7ce363": "1f8b08000000000000fff2750c72775508cecc2d28cecfe302040000fffffb1d273b0e000000", + "5cfc8f95f98237a10affc14a76e3e20b": "1f8b08000000000000fff2757477f7745508cecc2d28cecfe302040000ffffb09167470f000000", + "6d8be986fa35821e7e869fbb118e51ba": "1f8b08000000000000fff2f0f7750d5208cecc2d28cecfe302040000fffffb2ef0a60e000000", + "99e5497ae5f5988fafafbcd15ed74d22": "1f8b08000000000000fff2f10c765408cecc2d28cecfe302040000ffffab9bc93e0d000000", + "bb006aa6261a80f6c52c640f713659c1": "1f8b08000000000000ff72720c0a5108cecc2d28cecfe302040000ffff89742ac20d000000", }) if err != nil { return err diff --git a/v2/jam/store/disk_tmpl.go b/v2/jam/store/disk_tmpl.go index cae5ba8..1779994 100644 --- a/v2/jam/store/disk_tmpl.go +++ b/v2/jam/store/disk_tmpl.go @@ -45,8 +45,7 @@ const diskGlobalBoxTmpl = ` func() { b := packr.New("{{.Box.Name}}", "{{.Box.Path}}") - {{ range $file := .Files -}} + {{- range $file := .Files }} b.SetResolver("{{$file.Resolver}}", packr.Pointer{ForwardBox: gk, ForwardPath: "{{$file.ForwardPath}}"}) - {{ end -}} - }() -` + {{- end }} + }()` diff --git a/v2/jam/store/fn.go b/v2/jam/store/fn.go index c9f5ea9..e16e466 100644 --- a/v2/jam/store/fn.go +++ b/v2/jam/store/fn.go @@ -9,10 +9,10 @@ var _ Store = &FnStore{} type FnStore struct { - FileNamesFn func(*parser.Box) ([]string, error) - FilesFn func(*parser.Box) ([]*parser.File, error) - PackFn func(*parser.Box) error - CleanFn func(*parser.Box) error + FileNamesFn func(*parser.Box) ([]string, error) + FilesFn func(*parser.Box) ([]*parser.File, error) + PackFn func(*parser.Box) error + CleanFn func(*parser.Box) error } func (f *FnStore) FileNames(box *parser.Box) ([]string, error) { diff --git a/v2/jam/store/legacy.go b/v2/jam/store/legacy.go index afff64a..d75b4e2 100644 --- a/v2/jam/store/legacy.go +++ b/v2/jam/store/legacy.go @@ -17,13 +17,13 @@ type Legacy struct { *Disk - boxes map[string][]legacyBox + boxes map[string][]legacyBox } func NewLegacy() *Legacy { return &Legacy{ - Disk: NewDisk("", ""), - boxes: map[string][]legacyBox{}, + Disk: NewDisk("", ""), + boxes: map[string][]legacyBox{}, } } @@ -50,8 +50,8 @@ lbs := l.boxes[box.PackageDir] lbs = append(lbs, legacyBox{ - Box: box, - Files: fcs, + Box: box, + Files: fcs, }) l.boxes[box.PackageDir] = lbs return nil @@ -78,8 +78,8 @@ bx := b[0].Box pkg := bx.Package opts := map[string]interface{}{ - "Package": pkg, - "Boxes": b, + "Package": pkg, + "Boxes": b, } p := filepath.Join(bx.PackageDir, "a_"+bx.Package+"-packr.go.tmpl") tmpl, err := template.New(p).Parse(legacyTmpl) @@ -102,13 +102,13 @@ } type legacyBox struct { - Box *parser.Box - Files []legacyFile + Box *parser.Box + Files []legacyFile } type legacyFile struct { - Name string - Contents string + Name string + Contents string } var legacyTmpl = `// Code generated by github.com/gobuffalo/packr. DO NOT EDIT. @@ -122,7 +122,7 @@ func init() { {{- range $box := .Boxes }} {{- range $box.Files }} - packr.PackJSONBytes("{{$box.Box.Name}}", "{{.Name}}", "{{.Contents}}") + _ = packr.PackJSONBytes("{{$box.Box.Name}}", "{{.Name}}", "{{.Contents}}") {{- end }} {{- end }} } diff --git a/v2/packr.go b/v2/packr.go index 0c670b6..f0f88f1 100644 --- a/v2/packr.go +++ b/v2/packr.go @@ -4,9 +4,9 @@ "fmt" "github.com/gobuffalo/packr/v2/file/resolver" - "github.com/gobuffalo/packr/v2/internal/takeon/github.com/markbates/safe" "github.com/gobuffalo/packr/v2/jam/parser" "github.com/gobuffalo/packr/v2/plog" + "github.com/markbates/safe" ) var boxes = &boxMap{} diff --git a/v2/packr2/cmd/build.go b/v2/packr2/cmd/build.go index 747c460..47c2b44 100644 --- a/v2/packr2/cmd/build.go +++ b/v2/packr2/cmd/build.go @@ -8,9 +8,9 @@ ) var buildCmd = &cobra.Command{ - Use: "build", - Short: "Wraps the go build command with packr", - DisableFlagParsing: true, + Use: "build", + Short: "Wraps the go build command with packr", + DisableFlagParsing: true, RunE: func(cmd *cobra.Command, args []string) error { cargs := parseArgs(args) if globalOptions.Verbose { diff --git a/v2/packr2/cmd/clean.go b/v2/packr2/cmd/clean.go index 7d08855..0834b5d 100644 --- a/v2/packr2/cmd/clean.go +++ b/v2/packr2/cmd/clean.go @@ -6,8 +6,8 @@ ) var cleanCmd = &cobra.Command{ - Use: "clean", - Short: "removes any *-packr.go files", + Use: "clean", + Short: "removes any *-packr.go files", RunE: func(cmd *cobra.Command, args []string) error { return jam.Clean(args...) }, diff --git a/v2/packr2/cmd/fix/fix.go b/v2/packr2/cmd/fix/fix.go index 9053b14..ff923bf 100644 --- a/v2/packr2/cmd/fix/fix.go +++ b/v2/packr2/cmd/fix/fix.go @@ -6,11 +6,8 @@ "os" "strings" - "github.com/gobuffalo/envy" "github.com/gobuffalo/packr/v2/jam/store" ) - -var modsOn = (strings.TrimSpace(envy.Get("GO111MODULE", "off")) == "on") //YesToAll will be used by the command to skip the questions var YesToAll bool diff --git a/v2/packr2/cmd/fix.go b/v2/packr2/cmd/fix.go index f7d3a98..8496900 100644 --- a/v2/packr2/cmd/fix.go +++ b/v2/packr2/cmd/fix.go @@ -10,8 +10,8 @@ // fixCmd represents the info command var fixCmd = &cobra.Command{ - Use: "fix", - Short: fmt.Sprintf("will attempt to fix a application's API to match packr version %s", packr.Version), + Use: "fix", + Short: fmt.Sprintf("will attempt to fix a application's API to match packr version %s", packr.Version), RunE: func(cmd *cobra.Command, args []string) error { return fix.Run() }, diff --git a/v2/packr2/cmd/gocmd.go b/v2/packr2/cmd/gocmd.go index eb2e2f7..46d86da 100644 --- a/v2/packr2/cmd/gocmd.go +++ b/v2/packr2/cmd/gocmd.go @@ -7,7 +7,6 @@ "path/filepath" "strings" - "github.com/gobuffalo/envy" "github.com/gobuffalo/packr/v2/plog" ) @@ -55,7 +54,11 @@ } } - cp := exec.Command(envy.Get("GO_BIN", "go"), cargs...) + goBin := os.Getenv("GO_BIN") + if goBin == "" { + goBin = "go" + } + cp := exec.Command(goBin, cargs...) plog.Logger.Debug(strings.Join(cp.Args, " ")) cp.Stderr = os.Stderr cp.Stdin = os.Stdin diff --git a/v2/packr2/cmd/install.go b/v2/packr2/cmd/install.go index 1924614..ca8efe8 100644 --- a/v2/packr2/cmd/install.go +++ b/v2/packr2/cmd/install.go @@ -23,9 +23,9 @@ ` var installCmd = &cobra.Command{ - Use: "install", - Short: "Don't. ru", - DisableFlagParsing: true, + Use: "install", + Short: "Don't. ru", + DisableFlagParsing: true, RunE: func(cmd *cobra.Command, args []string) error { cargs := parseArgs(args) if globalOptions.Verbose { diff --git a/v2/packr2/cmd/root.go b/v2/packr2/cmd/root.go index 409a9b0..a4cdf6f 100644 --- a/v2/packr2/cmd/root.go +++ b/v2/packr2/cmd/root.go @@ -12,15 +12,15 @@ var globalOptions = struct { jam.PackOptions - Verbose bool - Silent bool + Verbose bool + Silent bool }{ PackOptions: jam.PackOptions{}, } var rootCmd = &cobra.Command{ - Use: "packr2", - Short: "Packr is a simple solution for bundling static assets inside of Go binaries.", + Use: "packr2", + Short: "Packr is a simple solution for bundling static assets inside of Go binaries.", PersistentPreRunE: func(cmd *cobra.Command, args []string) error { for _, a := range args { if a == "--legacy" { diff --git a/v2/packr2/cmd/version.go b/v2/packr2/cmd/version.go index e8b80be..46cb490 100644 --- a/v2/packr2/cmd/version.go +++ b/v2/packr2/cmd/version.go @@ -8,10 +8,10 @@ ) var versionCmd = &cobra.Command{ - Use: "version", - Short: "shows packr version", + Use: "version", + Short: "shows packr version", RunE: func(cmd *cobra.Command, args []string) error { - fmt.Print(packr.Version) + fmt.Println(packr.Version) return nil }, } diff --git a/v2/pointer.go b/v2/pointer.go index d342fe6..6e839dc 100644 --- a/v2/pointer.go +++ b/v2/pointer.go @@ -9,8 +9,8 @@ // Pointer is a resolvr which resolves // a file from a different box. type Pointer struct { - ForwardBox string - ForwardPath string + ForwardBox string + ForwardPath string } var _ resolver.Resolver = Pointer{} diff --git a/v2/pointer_test.go b/v2/pointer_test.go index 4a69d54..62e82d6 100644 --- a/v2/pointer_test.go +++ b/v2/pointer_test.go @@ -15,8 +15,8 @@ b2 := New("b2", "") b2.SetResolver("bar.txt", &Pointer{ - ForwardBox: "b1", - ForwardPath: "foo.txt", + ForwardBox: "b1", + ForwardPath: "foo.txt", }) s, err := b2.FindString("bar.txt") diff --git a/v2/version.go b/v2/version.go index 6e6fb38..58e0065 100644 --- a/v2/version.go +++ b/v2/version.go @@ -1,4 +1,4 @@ package packr // Version of Packr -const Version = "v2.5.1" +const Version = "v2.8.1" diff --git a/version.go b/version.go index bf736a7..db84824 100644 --- a/version.go +++ b/version.go @@ -1,3 +1,3 @@ package packr -const Version = "v1.30.1" +const Version = "v2.5.3"