Skip to content
This repository has been archived by the owner on Jun 25, 2022. It is now read-only.

Commit

Permalink
dep deit (#212)
Browse files Browse the repository at this point in the history
  • Loading branch information
markbates committed Jun 24, 2019
1 parent 4b81a88 commit bded308
Show file tree
Hide file tree
Showing 63 changed files with 803 additions and 251 deletions.
5 changes: 2 additions & 3 deletions box.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package packr
import (
"bytes"
"compress/gzip"
"fmt"
"io/ioutil"
"net/http"
"os"
Expand All @@ -11,14 +12,12 @@ import (
"runtime"
"strings"

"github.com/pkg/errors"

"github.com/gobuffalo/packd"
)

var (
// ErrResOutsideBox gets returned in case of the requested resources being outside the box
ErrResOutsideBox = errors.New("Can't find a resource outside the box")
ErrResOutsideBox = fmt.Errorf("Can't find a resource outside the box")
)

var _ packd.Box = Box{}
Expand Down
5 changes: 2 additions & 3 deletions builder/box.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ import (
"bytes"
"compress/gzip"
"encoding/json"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"

"github.com/pkg/errors"
)

type box struct {
Expand All @@ -25,7 +24,7 @@ func (b *box) Walk(root string) error {
}
if _, err := os.Stat(root); err != nil {
// return nil
return errors.Errorf("could not find folder for box: %s", root)
return fmt.Errorf("could not find folder for box: %s", root)
}
return filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
if info == nil || info.IsDir() || strings.HasSuffix(info.Name(), "-packr.go") {
Expand Down
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ go 1.12

require (
github.com/gobuffalo/envy v1.7.0
github.com/gobuffalo/packd v0.1.0
github.com/gobuffalo/packd v0.2.0
github.com/gobuffalo/packr/v2 v2.4.0
github.com/pkg/errors v0.8.1
github.com/spf13/cobra v0.0.5
github.com/stretchr/testify v1.3.0
golang.org/x/sync v0.0.0-20190423024810-112230192c58
Expand Down
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ 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 v0.0.0-20190315122211-86e12af44bc2 h1:8thhT+kUJMTMy3HlX4+y9Da+BNJck+p109tqqKp7WDs=
github.com/gobuffalo/logger v0.0.0-20190315122211-86e12af44bc2/go.mod h1:QdxcLw541hSGtBnhUc4gaNIXRjiDppFGaDqzbrBd3v8=
github.com/gobuffalo/packd v0.1.0 h1:4sGKOD8yaYJ+dek1FDkwcxCHA40M4kfKgFHx8N2kwbU=
github.com/gobuffalo/packd v0.1.0/go.mod h1:M2Juc+hhDXf/PnmBANFCqx4DM3wRbgDvnVWeG2RIxq4=
github.com/gobuffalo/packd v0.2.0 h1:9Mu1TYbSfH75zQIQtZEgHEaYeRR4485U4T9N1OQYrXk=
github.com/gobuffalo/packd v0.2.0/go.mod h1:k2CkHP3bjbqL2GwxwhxUy1DgnlbW644hkLC9iIUvZwY=
github.com/gobuffalo/packr/v2 v2.4.0 h1:FB8CdysPlcECofv3tpH21T4aJDWmv7NFq8m0X6JZMGc=
github.com/gobuffalo/packr/v2 v2.4.0/go.mod h1:ra341gygw9/61nSjAbfwcwh8IrYL4WmR4IsPkPBhQiY=
github.com/gobuffalo/syncx v0.0.0-20190224160051-33c29581e754 h1:tpom+2CJmpzAWj5/VEHync2rJGi+epHNIeRSWjzGA+4=
github.com/gobuffalo/syncx v0.0.0-20190224160051-33c29581e754/go.mod h1:HhnNqWY95UYwwW3uSASeV7vtgYkT2t16hJgV3AEPUpw=
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=
Expand Down Expand Up @@ -68,7 +68,6 @@ golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnf
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190422162423-af44ce270edf h1:pZmAoqqjjxp5rjcjFhHcvDR/nXjNA57G6oHPNFTguuw=
golang.org/x/crypto v0.0.0-20190422162423-af44ce270edf/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE=
golang.org/x/net v0.0.0-20190311183353-d8887717615a h1:oWX7TPOiFAMXLq8o0ikBYfCJVlRHBcsciT5bXOrH628=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
Expand All @@ -78,7 +77,6 @@ golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7w
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/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/tools v0.0.0-20190613204242-ed0dc450797f h1:+zypR5600WBcnJgA2nzZAsBlM8cArEGa8dhhiNE4u3w=
golang.org/x/tools v0.0.0-20190613204242-ed0dc450797f/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=
Expand Down
18 changes: 8 additions & 10 deletions v2/box.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,11 @@ import (
"sort"
"strings"

"errors"

"github.com/gobuffalo/packd"
"github.com/gobuffalo/packr/v2/file"
"github.com/gobuffalo/packr/v2/file/resolver"
"github.com/gobuffalo/packr/v2/plog"
"github.com/markbates/oncer"
"github.com/gobuffalo/packr/v2/internal/takeon/github.com/markbates/oncer"
)

var _ packd.Box = &Box{}
Expand All @@ -30,12 +28,12 @@ var _ packd.Finder = &Box{}
// 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
Expand Down Expand Up @@ -209,7 +207,7 @@ func (b *Box) Resolve(key string) (file.File, error) {
if r == nil {
r = resolver.DefaultResolver
if r == nil {
return nil, errors.New("resolver.DefaultResolver is nil")
return nil, fmt.Errorf("resolver.DefaultResolver is nil")
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions v2/box_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,9 @@ func Test_Box_Open(t *testing.T) {
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")

Expand Down
6 changes: 3 additions & 3 deletions v2/deprecated.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package packr

import (
"encoding/json"
"errors"
"fmt"

"github.com/gobuffalo/packr/v2/file"
"github.com/gobuffalo/packr/v2/file/resolver"
"github.com/markbates/oncer"
"github.com/gobuffalo/packr/v2/internal/takeon/github.com/markbates/oncer"
)

// File has been deprecated and file.File should be used instead
Expand All @@ -15,7 +15,7 @@ type File = file.File
var (
// ErrResOutsideBox gets returned in case of the requested resources being outside the box
// Deprecated
ErrResOutsideBox = errors.New("can't find a resource outside the box")
ErrResOutsideBox = fmt.Errorf("can't find a resource outside the box")
)

// PackBytes packs bytes for a file into a box.
Expand Down
10 changes: 5 additions & 5 deletions v2/file/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import (
)

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 {
Expand Down
4 changes: 2 additions & 2 deletions v2/file/resolver/disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ func (d *Disk) FileMap() map[string]file.File {
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)
Expand Down
41 changes: 20 additions & 21 deletions v2/file/resolver/encoding/hex/hex.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ package hex

import (
"bytes"
"errors"
"fmt"
"io"
)
Expand All @@ -16,7 +15,7 @@ const hextable = "0123456789abcdef"

// 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
Expand All @@ -34,7 +33,7 @@ func Encode(dst, src []byte) int {
// ErrLength reports an attempt to decode an odd-length input
// using Decode or DecodeString.
// The stream-based Decoder returns io.ErrUnexpectedEOF instead of ErrLength.
var ErrLength = errors.New("encoding/hex: odd length hex string")
var ErrLength = fmt.Errorf("encoding/hex: odd length hex string")

// InvalidByteError values describe errors resulting from an invalid byte in a hex string.
type InvalidByteError byte
Expand All @@ -45,7 +44,7 @@ func (e InvalidByteError) Error() string {

// 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.
Expand Down Expand Up @@ -127,9 +126,9 @@ func Dump(data []byte) string {
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.
Expand All @@ -154,10 +153,10 @@ func (e *encoder) Write(p []byte) (n int, err error) {
}

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.
Expand All @@ -170,7 +169,7 @@ func (d *decoder) Read(p []byte) (n int, err error) {
// 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 {
Expand All @@ -189,11 +188,11 @@ func (d *decoder) Read(p []byte) (n int, err error) {
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
}
Expand All @@ -206,12 +205,12 @@ func Dumper(w io.Writer) io.WriteCloser {
}

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 {
Expand All @@ -223,7 +222,7 @@ func toChar(b byte) byte {

func (h *dumper) Write(data []byte) (n int, err error) {
if h.closed {
return 0, errors.New("encoding/hex: dumper closed")
return 0, fmt.Errorf("encoding/hex: dumper closed")
}

// Output lines look like:
Expand Down
12 changes: 6 additions & 6 deletions v2/file/resolver/hex_gzip.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ import (
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 {
Expand Down Expand Up @@ -77,9 +77,9 @@ func NewHexGzip(files map[string]string) (*HexGzip, error) {
}

hg := &HexGzip{
packed: files,
unpacked: map[string]string{},
moot: &sync.RWMutex{},
packed: files,
unpacked: map[string]string{},
moot: &sync.RWMutex{},
}

return hg, nil
Expand Down
8 changes: 4 additions & 4 deletions v2/file/resolver/ident_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (

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" {
Expand All @@ -27,7 +27,7 @@ func Test_Ident_OsPath(t *testing.T) {

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",
}
}
15 changes: 6 additions & 9 deletions v2/go.mod
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
module github.com/gobuffalo/packr/v2

go 1.12

require (
github.com/gobuffalo/envy v1.7.0
github.com/gobuffalo/logger v0.0.0-20190315122211-86e12af44bc2
github.com/gobuffalo/packd v0.1.0
github.com/karrick/godirwalk v1.10.3
github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect
github.com/markbates/oncer v0.0.0-20181203154359-bf2de49a0be2
github.com/markbates/safe v1.0.1
github.com/pkg/errors v0.8.1
github.com/gobuffalo/logger v1.0.0
github.com/gobuffalo/packd v0.2.0
github.com/karrick/godirwalk v1.10.12
github.com/rogpeppe/go-internal v1.3.0
github.com/sirupsen/logrus v1.4.2
github.com/spf13/cobra v0.0.5
github.com/stretchr/testify v1.3.0
golang.org/x/crypto v0.0.0-20190422162423-af44ce270edf // indirect
golang.org/x/sync v0.0.0-20190423024810-112230192c58
golang.org/x/tools v0.0.0-20190613204242-ed0dc450797f
golang.org/x/tools v0.0.0-20190624150748-8ea4f8e3e5bf
)

0 comments on commit bded308

Please sign in to comment.