aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/gobuffalo/packr
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/gobuffalo/packr')
-rw-r--r--vendor/github.com/gobuffalo/packr/LICENSE.txt8
-rw-r--r--vendor/github.com/gobuffalo/packr/README.md145
-rw-r--r--vendor/github.com/gobuffalo/packr/box.go204
-rw-r--r--vendor/github.com/gobuffalo/packr/builder/box.go76
-rw-r--r--vendor/github.com/gobuffalo/packr/builder/builder.go168
-rw-r--r--vendor/github.com/gobuffalo/packr/builder/clean.go32
-rw-r--r--vendor/github.com/gobuffalo/packr/builder/file.go10
-rw-r--r--vendor/github.com/gobuffalo/packr/builder/pkg.go7
-rw-r--r--vendor/github.com/gobuffalo/packr/builder/tmpl.go18
-rw-r--r--vendor/github.com/gobuffalo/packr/builder/visitor.go248
-rw-r--r--vendor/github.com/gobuffalo/packr/env.go39
-rw-r--r--vendor/github.com/gobuffalo/packr/file.go15
-rw-r--r--vendor/github.com/gobuffalo/packr/file_info.go38
-rw-r--r--vendor/github.com/gobuffalo/packr/go.mod11
-rw-r--r--vendor/github.com/gobuffalo/packr/go.sum22
-rw-r--r--vendor/github.com/gobuffalo/packr/packr.go74
-rw-r--r--vendor/github.com/gobuffalo/packr/physical_file.go13
-rw-r--r--vendor/github.com/gobuffalo/packr/virtual_file.go57
-rw-r--r--vendor/github.com/gobuffalo/packr/walk.go63
19 files changed, 0 insertions, 1248 deletions
diff --git a/vendor/github.com/gobuffalo/packr/LICENSE.txt b/vendor/github.com/gobuffalo/packr/LICENSE.txt
deleted file mode 100644
index 3ccb336..0000000
--- a/vendor/github.com/gobuffalo/packr/LICENSE.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-The MIT License (MIT)
-Copyright (c) 2016 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/vendor/github.com/gobuffalo/packr/README.md b/vendor/github.com/gobuffalo/packr/README.md
deleted file mode 100644
index d1144b1..0000000
--- a/vendor/github.com/gobuffalo/packr/README.md
+++ /dev/null
@@ -1,145 +0,0 @@
-# packr
-
-[![GoDoc](https://godoc.org/github.com/gobuffalo/packr?status.svg)](https://godoc.org/github.com/gobuffalo/packr)
-
-Packr is a simple solution for bundling static assets inside of Go binaries. Most importantly it does it in a way that is friendly to developers while they are developing.
-
-## Intro Video
-
-To get an idea of the what and why of packr, please enjoy this short video: [https://vimeo.com/219863271](https://vimeo.com/219863271).
-
-## Installation
-
-```text
-$ go get -u github.com/gobuffalo/packr/...
-```
-
-## Usage
-
-### In Code
-
-The first step in using Packr is to create a new box. A box represents a folder on disk. Once you have a box you can get `string` or `[]byte` representations of the file.
-
-```go
-// set up a new box by giving it a (relative) path to a folder on disk:
-box := packr.NewBox("./templates")
-
-// Get the string representation of a file:
-html := box.String("index.html")
-
-// Get the string representation of a file, or an error if it doesn't exist:
-html, err := box.MustString("index.html")
-
-// Get the []byte representation of a file:
-html := box.Bytes("index.html")
-
-// Get the []byte representation of a file, or an error if it doesn't exist:
-html, err := box.MustBytes("index.html")
-```
-
-### What is a Box?
-
-A box represents a folder, and any sub-folders, on disk that you want to have access to in your binary. When compiling a binary using the `packr` CLI the contents of the folder will be converted into Go files that can be compiled inside of a "standard" go binary. Inside of the compiled binary the files will be read from memory. When working locally the files will be read directly off of disk. This is a seamless switch that doesn't require any special attention on your part.
-
-#### Example
-
-Assume the follow directory structure:
-
-```
-├── main.go
-└── templates
- ├── admin
- │   └── index.html
- └── index.html
-```
-
-The following program will read the `./templates/admin/index.html` file and print it out.
-
-```go
-package main
-
-import (
- "fmt"
-
- "github.com/gobuffalo/packr"
-)
-
-func main() {
- box := packr.NewBox("./templates")
-
- s := box.String("admin/index.html")
- fmt.Println(s)
-}
-```
-
-### Development Made Easy
-
-In order to get static files into a Go binary, those files must first be converted to Go code. To do that, Packr, ships with a few tools to help build binaries. See below.
-
-During development, however, it is painful to have to keep running a tool to compile those files.
-
-Packr uses the following resolution rules when looking for a file:
-
-1. Look for the file in-memory (inside a Go binary)
-1. Look for the file on disk (during development)
-
-Because Packr knows how to fall through to the file system, developers don't need to worry about constantly compiling their static files into a binary. They can work unimpeded.
-
-Packr takes file resolution a step further. When declaring a new box you use a relative path, `./templates`. When Packr recieves this call it calculates out the absolute path to that directory. By doing this it means you can be guaranteed that Packr can find your files correctly, even if you're not running in the directory that the box was created in. This helps with the problem of testing, where Go changes the `pwd` for each package, making relative paths difficult to work with. This is not a problem when using Packr.
-
----
-
-## Usage with HTTP
-
-A box implements the [`http.FileSystem`](https://golang.org/pkg/net/http/#FileSystemhttps://golang.org/pkg/net/http/#FileSystem) interface, meaning it can be used to serve static files.
-
-```go
-package main
-
-import (
- "net/http"
-
- "github.com/gobuffalo/packr"
-)
-
-func main() {
- box := packr.NewBox("./templates")
-
- http.Handle("/", http.FileServer(box))
- http.ListenAndServe(":3000", nil)
-}
-```
-
----
-
-## Building a Binary (the easy way)
-
-When it comes time to build, or install, your Go binary, simply use `packr build` or `packr install` just as you would `go build` or `go install`. All flags for the `go` tool are supported and everything works the way you expect, the only difference is your static assets are now bundled in the generated binary. If you want more control over how this happens, looking at the following section on building binaries (the hard way).
-
-## Building a Binary (the hard way)
-
-Before you build your Go binary, run the `packr` command first. It will look for all the boxes in your code and then generate `.go` files that pack the static files into bytes that can be bundled into the Go binary.
-
-```
-$ packr
-```
-
-Then run your `go build command` like normal.
-
-*NOTE*: It is not recommended to check-in these generated `-packr.go` files. They can be large, and can easily become out of date if not careful. It is recommended that you always run `packr clean` after running the `packr` tool.
-
-#### Cleaning Up
-
-When you're done it is recommended that you run the `packr clean` command. This will remove all of the generated files that Packr created for you.
-
-```
-$ packr clean
-```
-
-Why do you want to do this? Packr first looks to the information stored in these generated files, if the information isn't there it looks to disk. This makes it easy to work with in development.
-
----
-
-## Debugging
-
-The `packr` command passes all arguments down to the underlying `go` command, this includes the `-v` flag to print out `go build` information. Packr looks for the `-v` flag, and will turn on its own verbose logging. This is very useful for trying to understand what the `packr` command is doing when it is run.
diff --git a/vendor/github.com/gobuffalo/packr/box.go b/vendor/github.com/gobuffalo/packr/box.go
deleted file mode 100644
index d221101..0000000
--- a/vendor/github.com/gobuffalo/packr/box.go
+++ /dev/null
@@ -1,204 +0,0 @@
-package packr
-
-import (
- "bytes"
- "compress/gzip"
- "io/ioutil"
- "net/http"
- "os"
- "path"
- "path/filepath"
- "runtime"
- "strings"
-
- "github.com/pkg/errors"
-)
-
-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")
-)
-
-// NewBox returns a Box that can be used to
-// retrieve files from either disk or the embedded
-// binary.
-func NewBox(path string) Box {
- var cd string
- if !filepath.IsAbs(path) {
- _, filename, _, _ := runtime.Caller(1)
- cd = filepath.Dir(filename)
- }
-
- // this little hack courtesy of the `-cover` flag!!
- cov := filepath.Join("_test", "_obj_test")
- cd = strings.Replace(cd, string(filepath.Separator)+cov, "", 1)
- if !filepath.IsAbs(cd) && cd != "" {
- cd = filepath.Join(GoPath(), "src", cd)
- }
-
- return Box{
- Path: path,
- callingDir: cd,
- data: map[string][]byte{},
- }
-}
-
-// Box represent a folder on a disk you want to
-// have access to in the built Go binary.
-type Box struct {
- Path string
- callingDir string
- data map[string][]byte
- directories map[string]bool
-}
-
-// AddString converts t to a byteslice and delegates to AddBytes to add to b.data
-func (b Box) AddString(path string, t string) {
- b.AddBytes(path, []byte(t))
-}
-
-// AddBytes sets t in b.data by the given path
-func (b Box) AddBytes(path string, t []byte) {
- b.data[path] = t
-}
-
-// String of the file asked for or an empty string.
-func (b Box) String(name string) string {
- return string(b.Bytes(name))
-}
-
-// MustString returns either the string of the requested
-// file or an error if it can not be found.
-func (b Box) MustString(name string) (string, error) {
- bb, err := b.MustBytes(name)
- return string(bb), err
-}
-
-// Bytes of the file asked for or an empty byte slice.
-func (b Box) Bytes(name string) []byte {
- bb, _ := b.MustBytes(name)
- return bb
-}
-
-// MustBytes returns either the byte slice of the requested
-// file or an error if it can not be found.
-func (b Box) MustBytes(name string) ([]byte, error) {
- f, err := b.find(name)
- if err == nil {
- bb := &bytes.Buffer{}
- bb.ReadFrom(f)
- return bb.Bytes(), err
- }
- return nil, err
-}
-
-// Has returns true if the resource exists in the box
-func (b Box) Has(name string) bool {
- _, err := b.find(name)
- if err != nil {
- return false
- }
- return true
-}
-
-func (b Box) decompress(bb []byte) []byte {
- reader, err := gzip.NewReader(bytes.NewReader(bb))
- if err != nil {
- return bb
- }
- data, err := ioutil.ReadAll(reader)
- if err != nil {
- return bb
- }
- return data
-}
-
-func (b Box) find(name string) (File, error) {
- if bb, ok := b.data[name]; ok {
- return newVirtualFile(name, bb), nil
- }
- if b.directories == nil {
- b.indexDirectories()
- }
-
- cleanName := filepath.ToSlash(filepath.Clean(name))
- // Ensure name is not outside the box
- if strings.HasPrefix(cleanName, "../") {
- return nil, ErrResOutsideBox
- }
- // Absolute name is considered as relative to the box root
- cleanName = strings.TrimPrefix(cleanName, "/")
-
- // Try to get the resource from the box
- if _, ok := data[b.Path]; ok {
- if bb, ok := data[b.Path][cleanName]; ok {
- bb = b.decompress(bb)
- return newVirtualFile(cleanName, bb), nil
- }
- if _, ok := b.directories[cleanName]; ok {
- return newVirtualDir(cleanName), nil
- }
- if filepath.Ext(cleanName) != "" {
- // The Handler created by http.FileSystem checks for those errors and
- // returns http.StatusNotFound instead of http.StatusInternalServerError.
- return nil, os.ErrNotExist
- }
- return nil, os.ErrNotExist
- }
-
- // Not found in the box virtual fs, try to get it from the file system
- cleanName = filepath.FromSlash(cleanName)
- p := filepath.Join(b.callingDir, b.Path, cleanName)
- return fileFor(p, cleanName)
-}
-
-// Open returns a File using the http.File interface
-func (b Box) Open(name string) (http.File, error) {
- return b.find(name)
-}
-
-// List shows "What's in the box?"
-func (b Box) List() []string {
- var keys []string
-
- if b.data == nil || len(b.data) == 0 {
- b.Walk(func(path string, info File) error {
- finfo, _ := info.FileInfo()
- if !finfo.IsDir() {
- keys = append(keys, finfo.Name())
- }
- return nil
- })
- } else {
- for k := range b.data {
- keys = append(keys, k)
- }
- }
- return keys
-}
-
-func (b *Box) indexDirectories() {
- b.directories = map[string]bool{}
- if _, ok := data[b.Path]; ok {
- for name := range data[b.Path] {
- prefix, _ := path.Split(name)
- // Even on Windows the suffix appears to be a /
- prefix = strings.TrimSuffix(prefix, "/")
- b.directories[prefix] = true
- }
- }
-}
-
-func fileFor(p string, name string) (File, error) {
- fi, err := os.Stat(p)
- if err != nil {
- return nil, err
- }
- if fi.IsDir() {
- return newVirtualDir(p), nil
- }
- if bb, err := ioutil.ReadFile(p); err == nil {
- return newVirtualFile(name, bb), nil
- }
- return nil, os.ErrNotExist
-}
diff --git a/vendor/github.com/gobuffalo/packr/builder/box.go b/vendor/github.com/gobuffalo/packr/builder/box.go
deleted file mode 100644
index 8490455..0000000
--- a/vendor/github.com/gobuffalo/packr/builder/box.go
+++ /dev/null
@@ -1,76 +0,0 @@
-package builder
-
-import (
- "bytes"
- "compress/gzip"
- "encoding/json"
- "io/ioutil"
- "os"
- "path/filepath"
- "strings"
-
- "github.com/pkg/errors"
-)
-
-type box struct {
- Name string
- Files []file
- compress bool
-}
-
-func (b *box) Walk(root string) error {
- root, err := filepath.EvalSymlinks(root)
- if err != nil {
- return errors.WithStack(err)
- }
- if _, err := os.Stat(root); err != nil {
- // return nil
- return errors.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") {
- return nil
- }
- name := strings.Replace(path, root+string(os.PathSeparator), "", 1)
- name = strings.Replace(name, "\\", "/", -1)
- f := file{
- Name: name,
- }
-
- DebugLog("packing file %s\n", f.Name)
-
- bb, err := ioutil.ReadFile(path)
- if err != nil {
- return errors.WithStack(err)
- }
- if b.compress {
- bb, err = compressFile(bb)
- if err != nil {
- return errors.WithStack(err)
- }
- }
- bb, err = json.Marshal(bb)
- if err != nil {
- return errors.WithStack(err)
- }
- f.Contents = strings.Replace(string(bb), "\"", "\\\"", -1)
-
- DebugLog("packed file %s\n", f.Name)
- b.Files = append(b.Files, f)
- return nil
- })
-}
-
-func compressFile(bb []byte) ([]byte, error) {
- var buf bytes.Buffer
- writer := gzip.NewWriter(&buf)
- _, err := writer.Write(bb)
- if err != nil {
- return bb, errors.WithStack(err)
- }
- err = writer.Close()
- if err != nil {
- return bb, errors.WithStack(err)
- }
- return buf.Bytes(), nil
-}
diff --git a/vendor/github.com/gobuffalo/packr/builder/builder.go b/vendor/github.com/gobuffalo/packr/builder/builder.go
deleted file mode 100644
index c689500..0000000
--- a/vendor/github.com/gobuffalo/packr/builder/builder.go
+++ /dev/null
@@ -1,168 +0,0 @@
-package builder
-
-import (
- "context"
- "os"
- "path/filepath"
- "regexp"
- "strings"
- "sync"
- "text/template"
-
- "github.com/pkg/errors"
- "golang.org/x/sync/errgroup"
-)
-
-var DebugLog func(string, ...interface{})
-
-func init() {
- DebugLog = func(string, ...interface{}) {}
-}
-
-var invalidFilePattern = regexp.MustCompile(`(_test|-packr).go$`)
-
-// Builder scans folders/files looking for `packr.NewBox` and then compiling
-// the required static files into `<package-name>-packr.go` files so they can
-// be built into Go binaries.
-type Builder struct {
- context.Context
- RootPath string
- IgnoredBoxes []string
- IgnoredFolders []string
- pkgs map[string]pkg
- moot *sync.Mutex
- Compress bool
-}
-
-// Run the builder.
-func (b *Builder) Run() error {
- wg := &errgroup.Group{}
- root, err := filepath.EvalSymlinks(b.RootPath)
- if err != nil {
- return errors.WithStack(err)
- }
- err = filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
- if info == nil {
- return filepath.SkipDir
- }
-
- base := strings.ToLower(filepath.Base(path))
- if strings.HasPrefix(base, "_") {
- return filepath.SkipDir
- }
- for _, f := range b.IgnoredFolders {
- if strings.ToLower(f) == base {
- return filepath.SkipDir
- }
- }
- if !info.IsDir() {
- wg.Go(func() error {
- return b.process(path)
- })
- }
- return nil
- })
- if err != nil {
- return errors.WithStack(err)
- }
- if err := wg.Wait(); err != nil {
- return errors.WithStack(err)
- }
- return b.dump()
-}
-
-func (b *Builder) dump() error {
- for _, p := range b.pkgs {
- name := filepath.Join(p.Dir, "a_"+p.Name+"-packr.go")
- f, err := os.Create(name)
- defer f.Close()
- if err != nil {
- return errors.WithStack(err)
- }
- t, err := template.New("").Parse(tmpl)
-
- if err != nil {
- return errors.WithStack(err)
- }
- err = t.Execute(f, p)
- if err != nil {
- return errors.WithStack(err)
- }
- }
- return nil
-}
-
-func (b *Builder) process(path string) error {
- ext := filepath.Ext(path)
- if ext != ".go" || invalidFilePattern.MatchString(path) {
- return nil
- }
-
- v := newVisitor(path)
- if err := v.Run(); err != nil {
- return errors.WithStack(err)
- }
-
- pk := pkg{
- Dir: filepath.Dir(path),
- Boxes: []box{},
- Name: v.Package,
- }
-
- for _, n := range v.Boxes {
- var ignored bool
- for _, i := range b.IgnoredBoxes {
- if n == i {
- // this is an ignored box
- ignored = true
- break
- }
- }
- if ignored {
- continue
- }
- bx := &box{
- Name: n,
- Files: []file{},
- compress: b.Compress,
- }
- DebugLog("building box %s\n", bx.Name)
- p := filepath.Join(pk.Dir, bx.Name)
- if err := bx.Walk(p); err != nil {
- return errors.WithStack(err)
- }
- if len(bx.Files) > 0 {
- pk.Boxes = append(pk.Boxes, *bx)
- }
- DebugLog("built box %s with %q\n", bx.Name, bx.Files)
- }
-
- if len(pk.Boxes) > 0 {
- b.addPkg(pk)
- }
- return nil
-}
-
-func (b *Builder) addPkg(p pkg) {
- b.moot.Lock()
- defer b.moot.Unlock()
- if _, ok := b.pkgs[p.Name]; !ok {
- b.pkgs[p.Name] = p
- return
- }
- pp := b.pkgs[p.Name]
- pp.Boxes = append(pp.Boxes, p.Boxes...)
- b.pkgs[p.Name] = pp
-}
-
-// New Builder with a given context and path
-func New(ctx context.Context, path string) *Builder {
- return &Builder{
- Context: ctx,
- RootPath: path,
- IgnoredBoxes: []string{},
- IgnoredFolders: []string{"vendor", ".git", "node_modules", ".idea"},
- pkgs: map[string]pkg{},
- moot: &sync.Mutex{},
- }
-}
diff --git a/vendor/github.com/gobuffalo/packr/builder/clean.go b/vendor/github.com/gobuffalo/packr/builder/clean.go
deleted file mode 100644
index 688ebf5..0000000
--- a/vendor/github.com/gobuffalo/packr/builder/clean.go
+++ /dev/null
@@ -1,32 +0,0 @@
-package builder
-
-import (
- "fmt"
- "os"
- "path/filepath"
- "strings"
-
- "github.com/pkg/errors"
-)
-
-// Clean up an *-packr.go files
-func Clean(root string) {
- root, _ = filepath.EvalSymlinks(root)
- filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
- base := filepath.Base(path)
- if base == ".git" || base == "vendor" || base == "node_modules" {
- return filepath.SkipDir
- }
- if info == nil || info.IsDir() {
- return nil
- }
- if strings.Contains(base, "-packr.go") {
- err := os.Remove(path)
- if err != nil {
- fmt.Println(err)
- return errors.WithStack(err)
- }
- }
- return nil
- })
-}
diff --git a/vendor/github.com/gobuffalo/packr/builder/file.go b/vendor/github.com/gobuffalo/packr/builder/file.go
deleted file mode 100644
index d439d49..0000000
--- a/vendor/github.com/gobuffalo/packr/builder/file.go
+++ /dev/null
@@ -1,10 +0,0 @@
-package builder
-
-type file struct {
- Name string
- Contents string
-}
-
-func (f file) String() string {
- return f.Name
-}
diff --git a/vendor/github.com/gobuffalo/packr/builder/pkg.go b/vendor/github.com/gobuffalo/packr/builder/pkg.go
deleted file mode 100644
index fbad2ac..0000000
--- a/vendor/github.com/gobuffalo/packr/builder/pkg.go
+++ /dev/null
@@ -1,7 +0,0 @@
-package builder
-
-type pkg struct {
- Name string
- Dir string
- Boxes []box
-}
diff --git a/vendor/github.com/gobuffalo/packr/builder/tmpl.go b/vendor/github.com/gobuffalo/packr/builder/tmpl.go
deleted file mode 100644
index 2b335ad..0000000
--- a/vendor/github.com/gobuffalo/packr/builder/tmpl.go
+++ /dev/null
@@ -1,18 +0,0 @@
-package builder
-
-var tmpl = `// Code generated by github.com/gobuffalo/packr. DO NOT EDIT.
-
-package {{.Name}}
-
-import "github.com/gobuffalo/packr"
-
-// You can use the "packr clean" command to clean up this,
-// and any other packr generated files.
-func init() {
- {{- range $box := .Boxes }}
- {{- range .Files }}
- packr.PackJSONBytes("{{$box.Name}}", "{{.Name}}", "{{.Contents}}")
- {{- end }}
- {{- end }}
-}
-`
diff --git a/vendor/github.com/gobuffalo/packr/builder/visitor.go b/vendor/github.com/gobuffalo/packr/builder/visitor.go
deleted file mode 100644
index ea24bde..0000000
--- a/vendor/github.com/gobuffalo/packr/builder/visitor.go
+++ /dev/null
@@ -1,248 +0,0 @@
-package builder
-
-import (
- "go/ast"
- "go/parser"
- "go/token"
- "io/ioutil"
- "sort"
- "strings"
-
- "github.com/pkg/errors"
-)
-
-type visitor struct {
- Path string
- Package string
- Boxes []string
- Errors []error
-}
-
-func newVisitor(path string) *visitor {
- return &visitor{
- Path: path,
- Boxes: []string{},
- Errors: []error{},
- }
-}
-
-func (v *visitor) Run() error {
- b, err := ioutil.ReadFile(v.Path)
- if err != nil {
- return errors.WithStack(err)
- }
-
- fset := token.NewFileSet()
- file, err := parser.ParseFile(fset, v.Path, string(b), parser.ParseComments)
- if err != nil {
- return errors.WithStack(err)
- }
-
- v.Package = file.Name.Name
- ast.Walk(v, file)
-
- m := map[string]string{}
- for _, s := range v.Boxes {
- m[s] = s
- }
- v.Boxes = []string{}
- for k := range m {
- v.Boxes = append(v.Boxes, k)
- }
-
- sort.Strings(v.Boxes)
-
- if len(v.Errors) > 0 {
- s := make([]string, len(v.Errors))
- for i, e := range v.Errors {
- s[i] = e.Error()
- }
- return errors.New(strings.Join(s, "\n"))
- }
- return nil
-}
-
-func (v *visitor) Visit(node ast.Node) ast.Visitor {
- if node == nil {
- return v
- }
- if err := v.eval(node); err != nil {
- v.Errors = append(v.Errors, err)
- }
- return v
-}
-
-func (v *visitor) eval(node ast.Node) error {
- switch t := node.(type) {
- case *ast.CallExpr:
- return v.evalExpr(t)
- case *ast.Ident:
- return v.evalIdent(t)
- case *ast.GenDecl:
- for _, n := range t.Specs {
- if err := v.eval(n); err != nil {
- return errors.WithStack(err)
- }
- }
- case *ast.FuncDecl:
- if t.Body == nil {
- return nil
- }
- for _, b := range t.Body.List {
- if err := v.evalStmt(b); err != nil {
- return errors.WithStack(err)
- }
- }
- return nil
- case *ast.ValueSpec:
- for _, e := range t.Values {
- if err := v.evalExpr(e); err != nil {
- return errors.WithStack(err)
- }
- }
- }
- return nil
-}
-
-func (v *visitor) evalStmt(stmt ast.Stmt) error {
- switch t := stmt.(type) {
- case *ast.ExprStmt:
- return v.evalExpr(t.X)
- case *ast.AssignStmt:
- for _, e := range t.Rhs {
- if err := v.evalArgs(e); err != nil {
- return errors.WithStack(err)
- }
- }
- }
- return nil
-}
-
-func (v *visitor) evalExpr(expr ast.Expr) error {
- switch t := expr.(type) {
- case *ast.CallExpr:
- if t.Fun == nil {
- return nil
- }
- for _, a := range t.Args {
- switch at := a.(type) {
- case *ast.CallExpr:
- if sel, ok := t.Fun.(*ast.SelectorExpr); ok {
- return v.evalSelector(at, sel)
- }
-
- if err := v.evalArgs(at); err != nil {
- return errors.WithStack(err)
- }
- case *ast.CompositeLit:
- for _, e := range at.Elts {
- if err := v.evalExpr(e); err != nil {
- return errors.WithStack(err)
- }
- }
- }
- }
- if ft, ok := t.Fun.(*ast.SelectorExpr); ok {
- return v.evalSelector(t, ft)
- }
- case *ast.KeyValueExpr:
- return v.evalExpr(t.Value)
- }
- return nil
-}
-
-func (v *visitor) evalArgs(expr ast.Expr) error {
- switch at := expr.(type) {
- case *ast.CompositeLit:
- for _, e := range at.Elts {
- if err := v.evalExpr(e); err != nil {
- return errors.WithStack(err)
- }
- }
- // case *ast.BasicLit:
- // fmt.Println("evalArgs", at.Value)
- // v.addBox(at.Value)
- case *ast.CallExpr:
- if at.Fun == nil {
- return nil
- }
- switch st := at.Fun.(type) {
- case *ast.SelectorExpr:
- if err := v.evalSelector(at, st); err != nil {
- return errors.WithStack(err)
- }
- case *ast.Ident:
- return v.evalIdent(st)
- }
- for _, a := range at.Args {
- if err := v.evalArgs(a); err != nil {
- return errors.WithStack(err)
- }
- }
- }
- return nil
-}
-
-func (v *visitor) evalSelector(expr *ast.CallExpr, sel *ast.SelectorExpr) error {
- x, ok := sel.X.(*ast.Ident)
- if !ok {
- return nil
- }
- if x.Name == "packr" && sel.Sel.Name == "NewBox" {
- for _, e := range expr.Args {
- switch at := e.(type) {
- case *ast.Ident:
- switch at.Obj.Kind {
- case ast.Var:
- if as, ok := at.Obj.Decl.(*ast.AssignStmt); ok {
- v.addVariable(as)
- }
- case ast.Con:
- if vs, ok := at.Obj.Decl.(*ast.ValueSpec); ok {
- v.addConstant(vs)
- }
- }
- return v.evalIdent(at)
- case *ast.BasicLit:
- v.addBox(at.Value)
- case *ast.CallExpr:
- return v.evalExpr(at)
- }
- }
- }
-
- return nil
-}
-
-func (v *visitor) evalIdent(i *ast.Ident) error {
- if i.Obj == nil {
- return nil
- }
- if s, ok := i.Obj.Decl.(*ast.AssignStmt); ok {
- return v.evalStmt(s)
- }
- return nil
-}
-
-func (v *visitor) addBox(b string) {
- b = strings.Replace(b, "\"", "", -1)
- v.Boxes = append(v.Boxes, b)
-}
-
-func (v *visitor) addVariable(as *ast.AssignStmt) error {
- if len(as.Rhs) == 1 {
- if bs, ok := as.Rhs[0].(*ast.BasicLit); ok {
- v.addBox(bs.Value)
- }
- }
- return nil
-}
-
-func (v *visitor) addConstant(vs *ast.ValueSpec) error {
- if len(vs.Values) == 1 {
- if bs, ok := vs.Values[0].(*ast.BasicLit); ok {
- v.addBox(bs.Value)
- }
- }
- return nil
-}
diff --git a/vendor/github.com/gobuffalo/packr/env.go b/vendor/github.com/gobuffalo/packr/env.go
deleted file mode 100644
index c52e73a..0000000
--- a/vendor/github.com/gobuffalo/packr/env.go
+++ /dev/null
@@ -1,39 +0,0 @@
-package packr
-
-import (
- "os"
- "os/exec"
- "path/filepath"
- "strings"
- "sync"
-)
-
-var goPath = filepath.Join(os.Getenv("HOME"), "go")
-
-func init() {
- var once sync.Once
- once.Do(func() {
- cmd := exec.Command("go", "env", "GOPATH")
- b, err := cmd.CombinedOutput()
- if err != nil {
- return
- }
- goPath = strings.TrimSpace(string(b))
- })
-}
-
-// GoPath returns the current GOPATH env var
-// or if it's missing, the default.
-func GoPath() string {
- return goPath
-}
-
-// GoBin returns the current GO_BIN env var
-// or if it's missing, a default of "go"
-func GoBin() string {
- go_bin := os.Getenv("GO_BIN")
- if go_bin == "" {
- return "go"
- }
- return go_bin
-}
diff --git a/vendor/github.com/gobuffalo/packr/file.go b/vendor/github.com/gobuffalo/packr/file.go
deleted file mode 100644
index 8337d62..0000000
--- a/vendor/github.com/gobuffalo/packr/file.go
+++ /dev/null
@@ -1,15 +0,0 @@
-package packr
-
-import (
- "io"
- "os"
-)
-
-type File interface {
- io.ReadCloser
- io.Writer
- FileInfo() (os.FileInfo, error)
- Readdir(count int) ([]os.FileInfo, error)
- Seek(offset int64, whence int) (int64, error)
- Stat() (os.FileInfo, error)
-}
diff --git a/vendor/github.com/gobuffalo/packr/file_info.go b/vendor/github.com/gobuffalo/packr/file_info.go
deleted file mode 100644
index e7931d2..0000000
--- a/vendor/github.com/gobuffalo/packr/file_info.go
+++ /dev/null
@@ -1,38 +0,0 @@
-package packr
-
-import (
- "os"
- "time"
-)
-
-type fileInfo struct {
- Path string
- Contents []byte
- size int64
- modTime time.Time
- isDir bool
-}
-
-func (f fileInfo) Name() string {
- return f.Path
-}
-
-func (f fileInfo) Size() int64 {
- return f.size
-}
-
-func (f fileInfo) Mode() os.FileMode {
- return 0444
-}
-
-func (f fileInfo) ModTime() time.Time {
- return f.modTime
-}
-
-func (f fileInfo) IsDir() bool {
- return f.isDir
-}
-
-func (f fileInfo) Sys() interface{} {
- return nil
-}
diff --git a/vendor/github.com/gobuffalo/packr/go.mod b/vendor/github.com/gobuffalo/packr/go.mod
deleted file mode 100644
index 55ed22e..0000000
--- a/vendor/github.com/gobuffalo/packr/go.mod
+++ /dev/null
@@ -1,11 +0,0 @@
-module github.com/gobuffalo/packr
-
-require (
- github.com/markbates/grift v1.0.1
- github.com/pkg/errors v0.8.0
- github.com/spf13/cobra v0.0.3
- github.com/spf13/pflag v1.0.2 // indirect
- github.com/stretchr/testify v1.2.2
- golang.org/x/net v0.0.0-20180811021610-c39426892332 // indirect
- golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f
-)
diff --git a/vendor/github.com/gobuffalo/packr/go.sum b/vendor/github.com/gobuffalo/packr/go.sum
deleted file mode 100644
index 020cd47..0000000
--- a/vendor/github.com/gobuffalo/packr/go.sum
+++ /dev/null
@@ -1,22 +0,0 @@
-github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
-github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
-github.com/markbates/grift v1.0.0/go.mod h1:6qyNEZSY8v6duE2tBtO/tPgBvxhT7g7DnQoIYpEyCfw=
-github.com/markbates/grift v1.0.1 h1:n3yUdXi+qdChTRvVCbRmD9iMLjSzv7ainzW3qYTP284=
-github.com/markbates/grift v1.0.1/go.mod h1:aC7s7OfCOzc2WCafmTm7wI3cfGFA/8opYhdTGlIAmmo=
-github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw=
-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/spf13/cobra v0.0.3 h1:ZlrZ4XsMRm04Fr5pSFxBgfND2EBVa1nLpiy1stUsX/8=
-github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
-github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
-github.com/spf13/pflag v1.0.2 h1:Fy0orTDgHdbnzHcsOgfCN4LtHf0ec3wwtiwJqwvf3Gc=
-github.com/spf13/pflag v1.0.2/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
-github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
-github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
-golang.org/x/net v0.0.0-20180808004115-f9ce57c11b24 h1:mEsFm194MmS9vCwxFy+zwu0EU7ZkxxMD1iH++vmGdUY=
-golang.org/x/net v0.0.0-20180808004115-f9ce57c11b24/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
-golang.org/x/net v0.0.0-20180811021610-c39426892332 h1:efGso+ep0DjyCBJPjvoz0HI6UldX4Md2F1rZFe1ir0E=
-golang.org/x/net v0.0.0-20180811021610-c39426892332/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
-golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f h1:wMNYb4v58l5UBM7MYRLPG6ZhfOqbKu7X5eyFl8ZhKvA=
-golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
diff --git a/vendor/github.com/gobuffalo/packr/packr.go b/vendor/github.com/gobuffalo/packr/packr.go
deleted file mode 100644
index 6ccc6c1..0000000
--- a/vendor/github.com/gobuffalo/packr/packr.go
+++ /dev/null
@@ -1,74 +0,0 @@
-package packr
-
-import (
- "bytes"
- "compress/gzip"
- "encoding/json"
- "runtime"
- "strings"
- "sync"
-)
-
-var gil = &sync.Mutex{}
-var data = map[string]map[string][]byte{}
-
-// PackBytes packs bytes for a file into a box.
-func PackBytes(box string, name string, bb []byte) {
- gil.Lock()
- defer gil.Unlock()
- if _, ok := data[box]; !ok {
- data[box] = map[string][]byte{}
- }
- data[box][name] = bb
-}
-
-// PackBytesGzip packets the gzipped compressed bytes into a box.
-func PackBytesGzip(box string, name string, bb []byte) error {
- var buf bytes.Buffer
- w := gzip.NewWriter(&buf)
- _, err := w.Write(bb)
- if err != nil {
- return err
- }
- err = w.Close()
- if err != nil {
- return err
- }
- PackBytes(box, name, buf.Bytes())
- return nil
-}
-
-// PackJSONBytes packs JSON encoded bytes for a file into a box.
-func PackJSONBytes(box string, name string, jbb string) error {
- var bb []byte
- err := json.Unmarshal([]byte(jbb), &bb)
- if err != nil {
- return err
- }
- PackBytes(box, name, bb)
- return nil
-}
-
-// UnpackBytes unpacks bytes for specific box.
-func UnpackBytes(box string) {
- gil.Lock()
- defer gil.Unlock()
- delete(data, box)
-}
-
-func osPaths(paths ...string) []string {
- if runtime.GOOS == "windows" {
- for i, path := range paths {
- paths[i] = strings.Replace(path, "/", "\\", -1)
- }
- }
-
- return paths
-}
-
-func osPath(path string) string {
- if runtime.GOOS == "windows" {
- return strings.Replace(path, "/", "\\", -1)
- }
- return path
-}
diff --git a/vendor/github.com/gobuffalo/packr/physical_file.go b/vendor/github.com/gobuffalo/packr/physical_file.go
deleted file mode 100644
index bf2d817..0000000
--- a/vendor/github.com/gobuffalo/packr/physical_file.go
+++ /dev/null
@@ -1,13 +0,0 @@
-package packr
-
-import "os"
-
-var _ File = physicalFile{}
-
-type physicalFile struct {
- *os.File
-}
-
-func (p physicalFile) FileInfo() (os.FileInfo, error) {
- return os.Stat(p.Name())
-}
diff --git a/vendor/github.com/gobuffalo/packr/virtual_file.go b/vendor/github.com/gobuffalo/packr/virtual_file.go
deleted file mode 100644
index 955db8c..0000000
--- a/vendor/github.com/gobuffalo/packr/virtual_file.go
+++ /dev/null
@@ -1,57 +0,0 @@
-package packr
-
-import (
- "bytes"
- "fmt"
- "os"
- "time"
-)
-
-var virtualFileModTime = time.Now()
-var _ File = virtualFile{}
-
-type virtualFile struct {
- *bytes.Reader
- Name string
- info fileInfo
-}
-
-func (f virtualFile) FileInfo() (os.FileInfo, error) {
- return f.info, nil
-}
-
-func (f virtualFile) Close() error {
- return nil
-}
-
-func (f virtualFile) Write(p []byte) (n int, err error) {
- return 0, fmt.Errorf("not implemented")
-}
-
-func (f virtualFile) Readdir(count int) ([]os.FileInfo, error) {
- return []os.FileInfo{f.info}, nil
-}
-
-func (f virtualFile) Stat() (os.FileInfo, error) {
- return f.info, nil
-}
-
-func newVirtualFile(name string, b []byte) File {
- return virtualFile{
- Reader: bytes.NewReader(b),
- Name: name,
- info: fileInfo{
- Path: name,
- Contents: b,
- size: int64(len(b)),
- modTime: virtualFileModTime,
- },
- }
-}
-
-func newVirtualDir(name string) File {
- var b []byte
- v := newVirtualFile(name, b).(virtualFile)
- v.info.isDir = true
- return v
-}
diff --git a/vendor/github.com/gobuffalo/packr/walk.go b/vendor/github.com/gobuffalo/packr/walk.go
deleted file mode 100644
index 21f2563..0000000
--- a/vendor/github.com/gobuffalo/packr/walk.go
+++ /dev/null
@@ -1,63 +0,0 @@
-package packr
-
-import (
- "os"
- "path/filepath"
- "strings"
-
- "github.com/pkg/errors"
-)
-
-type WalkFunc func(string, File) error
-
-// Walk will traverse the box and call the WalkFunc for each file in the box/folder.
-func (b Box) Walk(wf WalkFunc) error {
- if data[b.Path] == nil {
- base, err := filepath.EvalSymlinks(filepath.Join(b.callingDir, b.Path))
- if err != nil {
- return errors.WithStack(err)
- }
- return filepath.Walk(base, func(path string, info os.FileInfo, err error) error {
- cleanName, err := filepath.Rel(base, path)
- if err != nil {
- cleanName = strings.TrimPrefix(path, base)
- }
- cleanName = filepath.ToSlash(filepath.Clean(cleanName))
- cleanName = strings.TrimPrefix(cleanName, "/")
- cleanName = filepath.FromSlash(cleanName)
- if info == nil || info.IsDir() {
- return nil
- }
-
- file, err := fileFor(path, cleanName)
- if err != nil {
- return err
- }
- return wf(cleanName, file)
- })
- }
- for n := range data[b.Path] {
- f, err := b.find(n)
- if err != nil {
- return err
- }
- err = wf(n, f)
- if err != nil {
- return err
- }
- }
- return nil
-}
-
-// WalkPrefix will call box.Walk and call the WalkFunc when it finds paths that have a matching prefix
-func (b Box) WalkPrefix(prefix string, wf WalkFunc) error {
- opre := osPath(prefix)
- return b.Walk(func(path string, f File) error {
- if strings.HasPrefix(osPath(path), opre) {
- if err := wf(path, f); err != nil {
- return errors.WithStack(err)
- }
- }
- return nil
- })
-}