From 6197f455f695eb959a932e15dc417c1b50a2255b Mon Sep 17 00:00:00 2001 From: Christine Dodrill Date: Sun, 1 Jul 2018 20:38:18 +0000 Subject: vgo --- vendor/github.com/GeertJohan/go.rice/.gitignore | 8 - vendor/github.com/GeertJohan/go.rice/.travis.yml | 19 - vendor/github.com/GeertJohan/go.rice/AUTHORS | 4 - vendor/github.com/GeertJohan/go.rice/LICENSE | 22 - vendor/github.com/GeertJohan/go.rice/README.md | 151 ----- vendor/github.com/GeertJohan/go.rice/appended.go | 138 ----- vendor/github.com/GeertJohan/go.rice/box.go | 337 ---------- vendor/github.com/GeertJohan/go.rice/config.go | 39 -- .../github.com/GeertJohan/go.rice/config_test.go | 136 ----- vendor/github.com/GeertJohan/go.rice/debug.go | 4 - vendor/github.com/GeertJohan/go.rice/embedded.go | 90 --- .../GeertJohan/go.rice/embedded/embedded.go | 80 --- .../go.rice/example/example-files/file.txt | 2 - .../go.rice/example/example-files/img/doge.jpg | Bin 53549 -> 0 bytes .../go.rice/example/example-templates/message.tmpl | 1 - .../GeertJohan/go.rice/example/example.go | 69 --- vendor/github.com/GeertJohan/go.rice/file.go | 144 ----- vendor/github.com/GeertJohan/go.rice/http.go | 21 - .../github.com/GeertJohan/go.rice/rice/append.go | 157 ----- vendor/github.com/GeertJohan/go.rice/rice/clean.go | 33 - .../github.com/GeertJohan/go.rice/rice/embed-go.go | 161 ----- .../GeertJohan/go.rice/rice/embed-go_test.go | 680 --------------------- .../GeertJohan/go.rice/rice/embed-syso.go | 204 ------- vendor/github.com/GeertJohan/go.rice/rice/find.go | 150 ----- .../GeertJohan/go.rice/rice/find_test.go | 302 --------- vendor/github.com/GeertJohan/go.rice/rice/flags.go | 80 --- .../GeertJohan/go.rice/rice/identifier.go | 14 - vendor/github.com/GeertJohan/go.rice/rice/main.go | 68 --- .../GeertJohan/go.rice/rice/templates.go | 98 --- vendor/github.com/GeertJohan/go.rice/rice/util.go | 22 - .../GeertJohan/go.rice/rice/writecoff.go | 42 -- vendor/github.com/GeertJohan/go.rice/sort.go | 19 - vendor/github.com/GeertJohan/go.rice/virtual.go | 252 -------- vendor/github.com/GeertJohan/go.rice/walk.go | 122 ---- 34 files changed, 3669 deletions(-) delete mode 100644 vendor/github.com/GeertJohan/go.rice/.gitignore delete mode 100644 vendor/github.com/GeertJohan/go.rice/.travis.yml delete mode 100644 vendor/github.com/GeertJohan/go.rice/AUTHORS delete mode 100644 vendor/github.com/GeertJohan/go.rice/LICENSE delete mode 100644 vendor/github.com/GeertJohan/go.rice/README.md delete mode 100644 vendor/github.com/GeertJohan/go.rice/appended.go delete mode 100644 vendor/github.com/GeertJohan/go.rice/box.go delete mode 100644 vendor/github.com/GeertJohan/go.rice/config.go delete mode 100644 vendor/github.com/GeertJohan/go.rice/config_test.go delete mode 100644 vendor/github.com/GeertJohan/go.rice/debug.go delete mode 100644 vendor/github.com/GeertJohan/go.rice/embedded.go delete mode 100644 vendor/github.com/GeertJohan/go.rice/embedded/embedded.go delete mode 100644 vendor/github.com/GeertJohan/go.rice/example/example-files/file.txt delete mode 100644 vendor/github.com/GeertJohan/go.rice/example/example-files/img/doge.jpg delete mode 100644 vendor/github.com/GeertJohan/go.rice/example/example-templates/message.tmpl delete mode 100644 vendor/github.com/GeertJohan/go.rice/example/example.go delete mode 100644 vendor/github.com/GeertJohan/go.rice/file.go delete mode 100644 vendor/github.com/GeertJohan/go.rice/http.go delete mode 100644 vendor/github.com/GeertJohan/go.rice/rice/append.go delete mode 100644 vendor/github.com/GeertJohan/go.rice/rice/clean.go delete mode 100644 vendor/github.com/GeertJohan/go.rice/rice/embed-go.go delete mode 100644 vendor/github.com/GeertJohan/go.rice/rice/embed-go_test.go delete mode 100644 vendor/github.com/GeertJohan/go.rice/rice/embed-syso.go delete mode 100644 vendor/github.com/GeertJohan/go.rice/rice/find.go delete mode 100644 vendor/github.com/GeertJohan/go.rice/rice/find_test.go delete mode 100644 vendor/github.com/GeertJohan/go.rice/rice/flags.go delete mode 100644 vendor/github.com/GeertJohan/go.rice/rice/identifier.go delete mode 100644 vendor/github.com/GeertJohan/go.rice/rice/main.go delete mode 100644 vendor/github.com/GeertJohan/go.rice/rice/templates.go delete mode 100644 vendor/github.com/GeertJohan/go.rice/rice/util.go delete mode 100644 vendor/github.com/GeertJohan/go.rice/rice/writecoff.go delete mode 100644 vendor/github.com/GeertJohan/go.rice/sort.go delete mode 100644 vendor/github.com/GeertJohan/go.rice/virtual.go delete mode 100644 vendor/github.com/GeertJohan/go.rice/walk.go (limited to 'vendor/github.com/GeertJohan') diff --git a/vendor/github.com/GeertJohan/go.rice/.gitignore b/vendor/github.com/GeertJohan/go.rice/.gitignore deleted file mode 100644 index a3c9819..0000000 --- a/vendor/github.com/GeertJohan/go.rice/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -/example/example -/example/example.exe -/rice/rice -/rice/rice.exe - -*.rice-box.go -*.rice-box.syso -.wercker diff --git a/vendor/github.com/GeertJohan/go.rice/.travis.yml b/vendor/github.com/GeertJohan/go.rice/.travis.yml deleted file mode 100644 index b4840a1..0000000 --- a/vendor/github.com/GeertJohan/go.rice/.travis.yml +++ /dev/null @@ -1,19 +0,0 @@ -language: go - -go: - - master - - 1.x.x - - 1.8.x - - 1.7.x - - 1.6.x - - 1.5.x - -install: - - go get -t ./... - - env - - if [ "${TRAVIS_GO_VERSION%.*}" != "1.5" ]; then go get github.com/golang/lint/golint; fi -script: - - go build -x ./... - - go test -cover ./... - - go vet ./... - - if [ "${TRAVIS_GO_VERSION%.*}" != "1.5" ]; then golint .; fi diff --git a/vendor/github.com/GeertJohan/go.rice/AUTHORS b/vendor/github.com/GeertJohan/go.rice/AUTHORS deleted file mode 100644 index 20ff8ba..0000000 --- a/vendor/github.com/GeertJohan/go.rice/AUTHORS +++ /dev/null @@ -1,4 +0,0 @@ -Geert-Johan Riemer -Paul Maddox -Vincent Petithory - diff --git a/vendor/github.com/GeertJohan/go.rice/LICENSE b/vendor/github.com/GeertJohan/go.rice/LICENSE deleted file mode 100644 index 8b4409d..0000000 --- a/vendor/github.com/GeertJohan/go.rice/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -Copyright (c) 2013, Geert-Johan Riemer -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/vendor/github.com/GeertJohan/go.rice/README.md b/vendor/github.com/GeertJohan/go.rice/README.md deleted file mode 100644 index 836e671..0000000 --- a/vendor/github.com/GeertJohan/go.rice/README.md +++ /dev/null @@ -1,151 +0,0 @@ -## go.rice - -[![Build Status](https://travis-ci.org/GeertJohan/go.rice.png)](https://travis-ci.org/GeertJohan/go.rice) -[![Godoc](https://img.shields.io/badge/godoc-go.rice-blue.svg?style=flat-square)](https://godoc.org/github.com/GeertJohan/go.rice) - -go.rice is a [Go](http://golang.org) package that makes working with resources such as html,js,css,images and templates very easy. During development `go.rice` will load required files directly from disk. Upon deployment it is easy to add all resource files to a executable using the `rice` tool, without changing the source code for your package. go.rice provides several methods to add resources to a binary. - -### What does it do? -The first thing go.rice does is finding the correct absolute path for your resource files. Say you are executing go binary in your home directory, but your `html-files` are located in `$GOPATH/src/yourApplication/html-files`. `go.rice` will lookup the correct path for that directory (relative to the location of yourApplication). The only thing you have to do is include the resources using `rice.FindBox("html-files")`. - -This only works when the source is available to the machine executing the binary. Which is always the case when the binary was installed with `go get` or `go install`. It might occur that you wish to simply provide a binary, without source. The `rice` tool analyses source code and finds call's to `rice.FindBox(..)` and adds the required directories to the executable binary. There are several methods to add these resources. You can 'embed' by generating go source code, or append the resource to the executable as zip file. In both cases `go.rice` will detect the embedded or appended resources and load those, instead of looking up files from disk. - -### Installation - -Use `go get` to install the package the `rice` tool. -``` -go get github.com/GeertJohan/go.rice -go get github.com/GeertJohan/go.rice/rice -``` - -### Package usage - -Import the package: `import "github.com/GeertJohan/go.rice"` - -**Serving a static content folder over HTTP with a rice Box** -```go -http.Handle("/", http.FileServer(rice.MustFindBox("http-files").HTTPBox())) -http.ListenAndServe(":8080", nil) -``` - -**Service a static content folder over HTTP at a non-root location** -```go -box := rice.MustFindBox("cssfiles") -cssFileServer := http.StripPrefix("/css/", http.FileServer(box.HTTPBox())) -http.Handle("/css/", cssFileServer) -http.ListenAndServe(":8080", nil) -``` - -Note the *trailing slash* in `/css/` in both the call to -`http.StripPrefix` and `http.Handle`. - -**Loading a template** -```go -// find a rice.Box -templateBox, err := rice.FindBox("example-templates") -if err != nil { - log.Fatal(err) -} -// get file contents as string -templateString, err := templateBox.String("message.tmpl") -if err != nil { - log.Fatal(err) -} -// parse and execute the template -tmplMessage, err := template.New("message").Parse(templateString) -if err != nil { - log.Fatal(err) -} -tmplMessage.Execute(os.Stdout, map[string]string{"Message": "Hello, world!"}) - -``` - -Never call `FindBox()` or `MustFindBox()` from an `init()` function, as the boxes might have not been loaded at that time. - -### Tool usage -The `rice` tool lets you add the resources to a binary executable so the files are not loaded from the filesystem anymore. This creates a 'standalone' executable. There are several ways to add the resources to a binary, each has pro's and con's but all will work without requiring changes to the way you load the resources. - -#### embed-go -**Embed resources by generating Go source code** - -This method must be executed before building. It generates a single Go source file called *rice-box.go* for each package, that is compiled by the go compiler into the binary. - -The downside with this option is that the generated go source files can become very large, which will slow down compilation and require lots of memory to compile. - -Execute the following commands: -``` -rice embed-go -go build -``` - -*A Note on Symbolic Links*: `embed-go` uses the `os.Walk` function -from the standard library. The `os.Walk` function does **not** follow -symbolic links. So, when creating a box, be aware that any symbolic -links inside your box's directory will not be followed. **However**, -if the box itself is a symbolic link, its actual location will be -resolved first and then walked. In summary, if your box location is a -symbolic link, it will be followed but none of the symbolic links in -the box will be followed. - -#### embed-syso -**Embed resources by generating a coff .syso file and some .go source code** - -** This method is experimental and should not be used for production systems just yet ** - -This method must be executed before building. It generates a COFF .syso file and Go source file that are compiled by the go compiler into the binary. - -Execute the following commands: -``` -rice embed-syso -go build -``` - -#### append -**Append resources to executable as zip file** - -This method changes an already built executable. It appends the resources as zip file to the binary. It makes compilation a lot faster and can be used with large resource files. - -Downsides for appending are that it requires `zip` to be installed and does not provide a working Seek method. - -Run the following commands to create a standalone executable. -``` -go build -o example -rice append --exec example -``` - -**Note: requires zip command to be installed** - -On windows, install zip from http://gnuwin32.sourceforge.net/packages/zip.htm or cygwin/msys toolsets. - -#### Help information -Run `rice -h` for information about all options. - -You can run the -h option for each sub-command, e.g. `rice append -h`. - -### Order of precedence -When opening a new box, the rice package tries to locate the resources in the following order: - - - embedded in generated go source - - appended as zip - - 'live' from filesystem - - -### License -This project is licensed under a Simplified BSD license. Please read the [LICENSE file][license]. - -### TODO & Development -This package is not completed yet. Though it already provides working embedding, some important featuers are still missing. - - implement Readdir() correctly on virtualDir - - in-code TODO's - - find boxes in imported packages - -Less important stuff: - - idea, os/arch dependent embeds. rice checks if embedding file has _os_arch or build flags. If box is not requested by file without buildflags, then the buildflags are applied to the embed file. - -### Package documentation - -You will find package documentation at [godoc.org/github.com/GeertJohan/go.rice][godoc]. - - - [license]: https://github.com/GeertJohan/go.rice/blob/master/LICENSE - [godoc]: http://godoc.org/github.com/GeertJohan/go.rice diff --git a/vendor/github.com/GeertJohan/go.rice/appended.go b/vendor/github.com/GeertJohan/go.rice/appended.go deleted file mode 100644 index a986a0c..0000000 --- a/vendor/github.com/GeertJohan/go.rice/appended.go +++ /dev/null @@ -1,138 +0,0 @@ -package rice - -import ( - "archive/zip" - "log" - "os" - "path/filepath" - "strings" - "time" - - "github.com/daaku/go.zipexe" - "github.com/kardianos/osext" -) - -// appendedBox defines an appended box -type appendedBox struct { - Name string // box name - Files map[string]*appendedFile // appended files (*zip.File) by full path -} - -type appendedFile struct { - zipFile *zip.File - dir bool - dirInfo *appendedDirInfo - children []*appendedFile - content []byte -} - -// appendedBoxes is a public register of appendes boxes -var appendedBoxes = make(map[string]*appendedBox) - -func init() { - // find if exec is appended - thisFile, err := osext.Executable() - if err != nil { - return // not appended or cant find self executable - } - closer, rd, err := zipexe.OpenCloser(thisFile) - if err != nil { - return // not appended - } - defer closer.Close() - - for _, f := range rd.File { - // get box and file name from f.Name - fileParts := strings.SplitN(strings.TrimLeft(filepath.ToSlash(f.Name), "/"), "/", 2) - boxName := fileParts[0] - var fileName string - if len(fileParts) > 1 { - fileName = fileParts[1] - } - - // find box or create new one if doesn't exist - box := appendedBoxes[boxName] - if box == nil { - box = &appendedBox{ - Name: boxName, - Files: make(map[string]*appendedFile), - } - appendedBoxes[boxName] = box - } - - // create and add file to box - af := &appendedFile{ - zipFile: f, - } - if f.Comment == "dir" { - af.dir = true - af.dirInfo = &appendedDirInfo{ - name: filepath.Base(af.zipFile.Name), - //++ TODO: use zip modtime when that is set correctly: af.zipFile.ModTime() - time: time.Now(), - } - } else { - // this is a file, we need it's contents so we can create a bytes.Reader when the file is opened - // make a new byteslice - af.content = make([]byte, af.zipFile.FileInfo().Size()) - // ignore reading empty files from zip (empty file still is a valid file to be read though!) - if len(af.content) > 0 { - // open io.ReadCloser - rc, err := af.zipFile.Open() - if err != nil { - af.content = nil // this will cause an error when the file is being opened or seeked (which is good) - // TODO: it's quite blunt to just log this stuff. but this is in init, so rice.Debug can't be changed yet.. - log.Printf("error opening appended file %s: %v", af.zipFile.Name, err) - } else { - _, err = rc.Read(af.content) - rc.Close() - if err != nil { - af.content = nil // this will cause an error when the file is being opened or seeked (which is good) - // TODO: it's quite blunt to just log this stuff. but this is in init, so rice.Debug can't be changed yet.. - log.Printf("error reading data for appended file %s: %v", af.zipFile.Name, err) - } - } - } - } - - // add appendedFile to box file list - box.Files[fileName] = af - - // add to parent dir (if any) - dirName := filepath.Dir(fileName) - if dirName == "." { - dirName = "" - } - if fileName != "" { // don't make box root dir a child of itself - if dir := box.Files[dirName]; dir != nil { - dir.children = append(dir.children, af) - } - } - } -} - -// implements os.FileInfo. -// used for Readdir() -type appendedDirInfo struct { - name string - time time.Time -} - -func (adi *appendedDirInfo) Name() string { - return adi.name -} -func (adi *appendedDirInfo) Size() int64 { - return 0 -} -func (adi *appendedDirInfo) Mode() os.FileMode { - return os.ModeDir -} -func (adi *appendedDirInfo) ModTime() time.Time { - return adi.time -} -func (adi *appendedDirInfo) IsDir() bool { - return true -} -func (adi *appendedDirInfo) Sys() interface{} { - return nil -} diff --git a/vendor/github.com/GeertJohan/go.rice/box.go b/vendor/github.com/GeertJohan/go.rice/box.go deleted file mode 100644 index 71482e2..0000000 --- a/vendor/github.com/GeertJohan/go.rice/box.go +++ /dev/null @@ -1,337 +0,0 @@ -package rice - -import ( - "bytes" - "errors" - "fmt" - "io/ioutil" - "os" - "path/filepath" - "runtime" - "strings" - "time" - - "github.com/GeertJohan/go.rice/embedded" -) - -// Box abstracts a directory for resources/files. -// It can either load files from disk, or from embedded code (when `rice --embed` was ran). -type Box struct { - name string - absolutePath string - embed *embedded.EmbeddedBox - appendd *appendedBox -} - -var defaultLocateOrder = []LocateMethod{LocateEmbedded, LocateAppended, LocateFS} - -func findBox(name string, order []LocateMethod) (*Box, error) { - b := &Box{name: name} - - // no support for absolute paths since gopath can be different on different machines. - // therefore, required box must be located relative to package requiring it. - if filepath.IsAbs(name) { - return nil, errors.New("given name/path is absolute") - } - - var err error - for _, method := range order { - switch method { - case LocateEmbedded: - if embed := embedded.EmbeddedBoxes[name]; embed != nil { - b.embed = embed - return b, nil - } - - case LocateAppended: - appendedBoxName := strings.Replace(name, `/`, `-`, -1) - if appendd := appendedBoxes[appendedBoxName]; appendd != nil { - b.appendd = appendd - return b, nil - } - - case LocateFS: - // resolve absolute directory path - err := b.resolveAbsolutePathFromCaller() - if err != nil { - continue - } - // check if absolutePath exists on filesystem - info, err := os.Stat(b.absolutePath) - if err != nil { - continue - } - // check if absolutePath is actually a directory - if !info.IsDir() { - err = errors.New("given name/path is not a directory") - continue - } - return b, nil - case LocateWorkingDirectory: - // resolve absolute directory path - err := b.resolveAbsolutePathFromWorkingDirectory() - if err != nil { - continue - } - // check if absolutePath exists on filesystem - info, err := os.Stat(b.absolutePath) - if err != nil { - continue - } - // check if absolutePath is actually a directory - if !info.IsDir() { - err = errors.New("given name/path is not a directory") - continue - } - return b, nil - } - } - - if err == nil { - err = fmt.Errorf("could not locate box %q", name) - } - - return nil, err -} - -// FindBox returns a Box instance for given name. -// When the given name is a relative path, it's base path will be the calling pkg/cmd's source root. -// When the given name is absolute, it's absolute. derp. -// Make sure the path doesn't contain any sensitive information as it might be placed into generated go source (embedded). -func FindBox(name string) (*Box, error) { - return findBox(name, defaultLocateOrder) -} - -// MustFindBox returns a Box instance for given name, like FindBox does. -// It does not return an error, instead it panics when an error occurs. -func MustFindBox(name string) *Box { - box, err := findBox(name, defaultLocateOrder) - if err != nil { - panic(err) - } - return box -} - -// This is injected as a mutable function literal so that we can mock it out in -// tests and return a fixed test file. -var resolveAbsolutePathFromCaller = func(name string, nStackFrames int) (string, error) { - _, callingGoFile, _, ok := runtime.Caller(nStackFrames) - if !ok { - return "", errors.New("couldn't find caller on stack") - } - - // resolve to proper path - pkgDir := filepath.Dir(callingGoFile) - // fix for go cover - const coverPath = "_test/_obj_test" - if !filepath.IsAbs(pkgDir) { - if i := strings.Index(pkgDir, coverPath); i >= 0 { - pkgDir = pkgDir[:i] + pkgDir[i+len(coverPath):] // remove coverPath - pkgDir = filepath.Join(os.Getenv("GOPATH"), "src", pkgDir) // make absolute - } - } - return filepath.Join(pkgDir, name), nil -} - -func (b *Box) resolveAbsolutePathFromCaller() error { - path, err := resolveAbsolutePathFromCaller(b.name, 4) - if err != nil { - return err - } - b.absolutePath = path - return nil - -} - -func (b *Box) resolveAbsolutePathFromWorkingDirectory() error { - path, err := os.Getwd() - if err != nil { - return err - } - b.absolutePath = filepath.Join(path, b.name) - return nil -} - -// IsEmbedded indicates wether this box was embedded into the application -func (b *Box) IsEmbedded() bool { - return b.embed != nil -} - -// IsAppended indicates wether this box was appended to the application -func (b *Box) IsAppended() bool { - return b.appendd != nil -} - -// Time returns how actual the box is. -// When the box is embedded, it's value is saved in the embedding code. -// When the box is live, this methods returns time.Now() -func (b *Box) Time() time.Time { - if b.IsEmbedded() { - return b.embed.Time - } - - //++ TODO: return time for appended box - - return time.Now() -} - -// Open opens a File from the box -// If there is an error, it will be of type *os.PathError. -func (b *Box) Open(name string) (*File, error) { - if Debug { - fmt.Printf("Open(%s)\n", name) - } - - if b.IsEmbedded() { - if Debug { - fmt.Println("Box is embedded") - } - - // trim prefix (paths are relative to box) - name = strings.TrimLeft(name, "/") - if Debug { - fmt.Printf("Trying %s\n", name) - } - - // search for file - ef := b.embed.Files[name] - if ef == nil { - if Debug { - fmt.Println("Didn't find file in embed") - } - // file not found, try dir - ed := b.embed.Dirs[name] - if ed == nil { - if Debug { - fmt.Println("Didn't find dir in embed") - } - // dir not found, error out - return nil, &os.PathError{ - Op: "open", - Path: name, - Err: os.ErrNotExist, - } - } - if Debug { - fmt.Println("Found dir. Returning virtual dir") - } - vd := newVirtualDir(ed) - return &File{virtualD: vd}, nil - } - - // box is embedded - if Debug { - fmt.Println("Found file. Returning virtual file") - } - vf := newVirtualFile(ef) - return &File{virtualF: vf}, nil - } - - if b.IsAppended() { - // trim prefix (paths are relative to box) - name = strings.TrimLeft(name, "/") - - // search for file - appendedFile := b.appendd.Files[name] - if appendedFile == nil { - return nil, &os.PathError{ - Op: "open", - Path: name, - Err: os.ErrNotExist, - } - } - - // create new file - f := &File{ - appendedF: appendedFile, - } - - // if this file is a directory, we want to be able to read and seek - if !appendedFile.dir { - // looks like malformed data in zip, error now - if appendedFile.content == nil { - return nil, &os.PathError{ - Op: "open", - Path: "name", - Err: errors.New("error reading data from zip file"), - } - } - // create new bytes.Reader - f.appendedFileReader = bytes.NewReader(appendedFile.content) - } - - // all done - return f, nil - } - - // perform os open - if Debug { - fmt.Printf("Using os.Open(%s)", filepath.Join(b.absolutePath, name)) - } - file, err := os.Open(filepath.Join(b.absolutePath, name)) - if err != nil { - return nil, err - } - return &File{realF: file}, nil -} - -// Bytes returns the content of the file with given name as []byte. -func (b *Box) Bytes(name string) ([]byte, error) { - file, err := b.Open(name) - if err != nil { - return nil, err - } - defer file.Close() - - content, err := ioutil.ReadAll(file) - if err != nil { - return nil, err - } - - return content, nil -} - -// MustBytes returns the content of the file with given name as []byte. -// panic's on error. -func (b *Box) MustBytes(name string) []byte { - bts, err := b.Bytes(name) - if err != nil { - panic(err) - } - return bts -} - -// String returns the content of the file with given name as string. -func (b *Box) String(name string) (string, error) { - // check if box is embedded, optimized fast path - if b.IsEmbedded() { - // find file in embed - ef := b.embed.Files[name] - if ef == nil { - return "", os.ErrNotExist - } - // return as string - return ef.Content, nil - } - - bts, err := b.Bytes(name) - if err != nil { - return "", err - } - return string(bts), nil -} - -// MustString returns the content of the file with given name as string. -// panic's on error. -func (b *Box) MustString(name string) string { - str, err := b.String(name) - if err != nil { - panic(err) - } - return str -} - -// Name returns the name of the box -func (b *Box) Name() string { - return b.name -} diff --git a/vendor/github.com/GeertJohan/go.rice/config.go b/vendor/github.com/GeertJohan/go.rice/config.go deleted file mode 100644 index 45eb398..0000000 --- a/vendor/github.com/GeertJohan/go.rice/config.go +++ /dev/null @@ -1,39 +0,0 @@ -package rice - -// LocateMethod defines how a box is located. -type LocateMethod int - -const ( - LocateFS = LocateMethod(iota) // Locate on the filesystem according to package path. - LocateAppended // Locate boxes appended to the executable. - LocateEmbedded // Locate embedded boxes. - LocateWorkingDirectory // Locate on the binary working directory -) - -// Config allows customizing the box lookup behavior. -type Config struct { - // LocateOrder defines the priority order that boxes are searched for. By - // default, the package global FindBox searches for embedded boxes first, - // then appended boxes, and then finally boxes on the filesystem. That - // search order may be customized by provided the ordered list here. Leaving - // out a particular method will omit that from the search space. For - // example, []LocateMethod{LocateEmbedded, LocateAppended} will never search - // the filesystem for boxes. - LocateOrder []LocateMethod -} - -// FindBox searches for boxes using the LocateOrder of the config. -func (c *Config) FindBox(boxName string) (*Box, error) { - return findBox(boxName, c.LocateOrder) -} - -// MustFindBox searches for boxes using the LocateOrder of the config, like -// FindBox does. It does not return an error, instead it panics when an error -// occurs. -func (c *Config) MustFindBox(boxName string) *Box { - box, err := findBox(boxName, c.LocateOrder) - if err != nil { - panic(err) - } - return box -} diff --git a/vendor/github.com/GeertJohan/go.rice/config_test.go b/vendor/github.com/GeertJohan/go.rice/config_test.go deleted file mode 100644 index b54296b..0000000 --- a/vendor/github.com/GeertJohan/go.rice/config_test.go +++ /dev/null @@ -1,136 +0,0 @@ -package rice - -import ( - "fmt" - "io/ioutil" - "testing" - - "github.com/GeertJohan/go.rice/embedded" -) - -// For all test code in this package, define a set of test boxes. -var eb1 *embedded.EmbeddedBox -var ab1, ab2 *appendedBox -var fsb1, fsb2, fsb3 string // paths to filesystem boxes -func init() { - var err error - - // Box1 exists in all three locations. - eb1 = &embedded.EmbeddedBox{Name: "box1"} - embedded.RegisterEmbeddedBox(eb1.Name, eb1) - ab1 = &appendedBox{Name: "box1"} - appendedBoxes["box1"] = ab1 - fsb1, err = ioutil.TempDir("", "box1") - if err != nil { - panic(err) - } - - // Box2 exists in only appended and FS. - ab2 = &appendedBox{Name: "box2"} - appendedBoxes["box2"] = ab2 - fsb2, err = ioutil.TempDir("", "box2") - if err != nil { - panic(err) - } - - // Box3 exists only on disk. - fsb3, err = ioutil.TempDir("", "box3") - if err != nil { - panic(err) - } - - // Also, replace the default filesystem lookup path to directly support the - // on-disk temp directories. - resolveAbsolutePathFromCaller = func(name string, n int) (string, error) { - if name == "box1" { - return fsb1, nil - } else if name == "box2" { - return fsb2, nil - } else if name == "box3" { - return fsb3, nil - } - return "", fmt.Errorf("Unknown box name: %q", name) - } -} - -func TestDefaultLookupOrder(t *testing.T) { - // Box1 exists in all three, so the default order should find the embedded. - b, err := FindBox("box1") - if err != nil { - t.Fatalf("Expected to find box1, got error: %v", err) - } - if b.embed != eb1 { - t.Fatalf("Expected to find embedded box, but got %#v", b) - } - - // Box2 exists in appended and FS, so find the appended. - b2, err := FindBox("box2") - if err != nil { - t.Fatalf("Expected to find box2, got error: %v", err) - } - if b2.appendd != ab2 { - t.Fatalf("Expected to find appended box, but got %#v", b2) - } - - // Box3 exists only on FS, so find it there. - b3, err := FindBox("box3") - if err != nil { - t.Fatalf("Expected to find box3, got error: %v", err) - } - if b3.absolutePath != fsb3 { - t.Fatalf("Expected to find FS box, but got %#v", b3) - } -} - -func TestConfigLocateOrder(t *testing.T) { - cfg := Config{LocateOrder: []LocateMethod{LocateFS, LocateAppended, LocateEmbedded}} - fsb := []string{fsb1, fsb2, fsb3} - // All 3 boxes have a FS backend, so we should always find that. - for i, boxName := range []string{"box1", "box2", "box3"} { - b, err := cfg.FindBox(boxName) - if err != nil { - t.Fatalf("Expected to find %q, got error: %v", boxName, err) - } - if b.absolutePath != fsb[i] { - t.Fatalf("Expected to find FS box, but got %#v", b) - } - } - - cfg.LocateOrder = []LocateMethod{LocateAppended, LocateFS, LocateEmbedded} - { - b, err := cfg.FindBox("box3") - if err != nil { - t.Fatalf("Expected to find box3, got error: %v", err) - } - if b.absolutePath != fsb3 { - t.Fatalf("Expected to find FS box, but got %#v", b) - } - } - { - b, err := cfg.FindBox("box2") - if err != nil { - t.Fatalf("Expected to find box2, got error: %v", err) - } - if b.appendd != ab2 { - t.Fatalf("Expected to find appended box, but got %#v", b) - } - } - - // What if we don't list all the locate methods? - cfg.LocateOrder = []LocateMethod{LocateEmbedded} - { - b, err := cfg.FindBox("box2") - if err == nil { - t.Fatalf("Expected not to find box2, but something was found: %#v", b) - } - } - { - b, err := cfg.FindBox("box1") - if err != nil { - t.Fatalf("Expected to find box2, got error: %v", err) - } - if b.embed != eb1 { - t.Fatalf("Expected to find embedded box, but got %#v", b) - } - } -} diff --git a/vendor/github.com/GeertJohan/go.rice/debug.go b/vendor/github.com/GeertJohan/go.rice/debug.go deleted file mode 100644 index 2e68c84..0000000 --- a/vendor/github.com/GeertJohan/go.rice/debug.go +++ /dev/null @@ -1,4 +0,0 @@ -package rice - -// Debug can be set to true to enable debugging. -var Debug = false diff --git a/vendor/github.com/GeertJohan/go.rice/embedded.go b/vendor/github.com/GeertJohan/go.rice/embedded.go deleted file mode 100644 index 4f03fe1..0000000 --- a/vendor/github.com/GeertJohan/go.rice/embedded.go +++ /dev/null @@ -1,90 +0,0 @@ -package rice - -import ( - "os" - "time" - - "github.com/GeertJohan/go.rice/embedded" -) - -// re-type to make exported methods invisible to user (godoc) -// they're not required for the user -// embeddedDirInfo implements os.FileInfo -type embeddedDirInfo embedded.EmbeddedDir - -// Name returns the base name of the directory -// (implementing os.FileInfo) -func (ed *embeddedDirInfo) Name() string { - return ed.Filename -} - -// Size always returns 0 -// (implementing os.FileInfo) -func (ed *embeddedDirInfo) Size() int64 { - return 0 -} - -// Mode returns the file mode bits -// (implementing os.FileInfo) -func (ed *embeddedDirInfo) Mode() os.FileMode { - return os.FileMode(0555 | os.ModeDir) // dr-xr-xr-x -} - -// ModTime returns the modification time -// (implementing os.FileInfo) -func (ed *embeddedDirInfo) ModTime() time.Time { - return ed.DirModTime -} - -// IsDir returns the abbreviation for Mode().IsDir() (always true) -// (implementing os.FileInfo) -func (ed *embeddedDirInfo) IsDir() bool { - return true -} - -// Sys returns the underlying data source (always nil) -// (implementing os.FileInfo) -func (ed *embeddedDirInfo) Sys() interface{} { - return nil -} - -// re-type to make exported methods invisible to user (godoc) -// they're not required for the user -// embeddedFileInfo implements os.FileInfo -type embeddedFileInfo embedded.EmbeddedFile - -// Name returns the base name of the file -// (implementing os.FileInfo) -func (ef *embeddedFileInfo) Name() string { - return ef.Filename -} - -// Size returns the length in bytes for regular files; system-dependent for others -// (implementing os.FileInfo) -func (ef *embeddedFileInfo) Size() int64 { - return int64(len(ef.Content)) -} - -// Mode returns the file mode bits -// (implementing os.FileInfo) -func (ef *embeddedFileInfo) Mode() os.FileMode { - return os.FileMode(0555) // r-xr-xr-x -} - -// ModTime returns the modification time -// (implementing os.FileInfo) -func (ef *embeddedFileInfo) ModTime() time.Time { - return ef.FileModTime -} - -// IsDir returns the abbreviation for Mode().IsDir() (always false) -// (implementing os.FileInfo) -func (ef *embeddedFileInfo) IsDir() bool { - return false -} - -// Sys returns the underlying data source (always nil) -// (implementing os.FileInfo) -func (ef *embeddedFileInfo) Sys() interface{} { - return nil -} diff --git a/vendor/github.com/GeertJohan/go.rice/embedded/embedded.go b/vendor/github.com/GeertJohan/go.rice/embedded/embedded.go deleted file mode 100644 index bba8e58..0000000 --- a/vendor/github.com/GeertJohan/go.rice/embedded/embedded.go +++ /dev/null @@ -1,80 +0,0 @@ -// Package embedded defines embedded data types that are shared between the go.rice package and generated code. -package embedded - -import ( - "fmt" - "path/filepath" - "strings" - "time" -) - -const ( - EmbedTypeGo = 0 - EmbedTypeSyso = 1 -) - -// EmbeddedBox defines an embedded box -type EmbeddedBox struct { - Name string // box name - Time time.Time // embed time - EmbedType int // kind of embedding - Files map[string]*EmbeddedFile // ALL embedded files by full path - Dirs map[string]*EmbeddedDir // ALL embedded dirs by full path -} - -// Link creates the ChildDirs and ChildFiles links in all EmbeddedDir's -func (e *EmbeddedBox) Link() { - for path, ed := range e.Dirs { - fmt.Println(path) - ed.ChildDirs = make([]*EmbeddedDir, 0) - ed.ChildFiles = make([]*EmbeddedFile, 0) - } - for path, ed := range e.Dirs { - parentDirpath, _ := filepath.Split(path) - if strings.HasSuffix(parentDirpath, "/") { - parentDirpath = parentDirpath[:len(parentDirpath)-1] - } - parentDir := e.Dirs[parentDirpath] - if parentDir == nil { - panic("parentDir `" + parentDirpath + "` is missing in embedded box") - } - parentDir.ChildDirs = append(parentDir.ChildDirs, ed) - } - for path, ef := range e.Files { - dirpath, _ := filepath.Split(path) - if strings.HasSuffix(dirpath, "/") { - dirpath = dirpath[:len(dirpath)-1] - } - dir := e.Dirs[dirpath] - if dir == nil { - panic("dir `" + dirpath + "` is missing in embedded box") - } - dir.ChildFiles = append(dir.ChildFiles, ef) - } -} - -// EmbeddedDir is instanced in the code generated by the rice tool and contains all necicary information about an embedded file -type EmbeddedDir struct { - Filename string - DirModTime time.Time - ChildDirs []*EmbeddedDir // direct childs, as returned by virtualDir.Readdir() - ChildFiles []*EmbeddedFile // direct childs, as returned by virtualDir.Readdir() -} - -// EmbeddedFile is instanced in the code generated by the rice tool and contains all necicary information about an embedded file -type EmbeddedFile struct { - Filename string // filename - FileModTime time.Time - Content string -} - -// EmbeddedBoxes is a public register of embedded boxes -var EmbeddedBoxes = make(map[string]*EmbeddedBox) - -// RegisterEmbeddedBox registers an EmbeddedBox -func RegisterEmbeddedBox(name string, box *EmbeddedBox) { - if _, exists := EmbeddedBoxes[name]; exists { - panic(fmt.Sprintf("EmbeddedBox with name `%s` exists already", name)) - } - EmbeddedBoxes[name] = box -} diff --git a/vendor/github.com/GeertJohan/go.rice/example/example-files/file.txt b/vendor/github.com/GeertJohan/go.rice/example/example-files/file.txt deleted file mode 100644 index 3154578..0000000 --- a/vendor/github.com/GeertJohan/go.rice/example/example-files/file.txt +++ /dev/null @@ -1,2 +0,0 @@ -test content -break \ No newline at end of file diff --git a/vendor/github.com/GeertJohan/go.rice/example/example-files/img/doge.jpg b/vendor/github.com/GeertJohan/go.rice/example/example-files/img/doge.jpg deleted file mode 100644 index 6660dc9..0000000 Binary files a/vendor/github.com/GeertJohan/go.rice/example/example-files/img/doge.jpg and /dev/null differ diff --git a/vendor/github.com/GeertJohan/go.rice/example/example-templates/message.tmpl b/vendor/github.com/GeertJohan/go.rice/example/example-templates/message.tmpl deleted file mode 100644 index 4b7638d..0000000 --- a/vendor/github.com/GeertJohan/go.rice/example/example-templates/message.tmpl +++ /dev/null @@ -1 +0,0 @@ -I have a message for you: {{.Message}} diff --git a/vendor/github.com/GeertJohan/go.rice/example/example.go b/vendor/github.com/GeertJohan/go.rice/example/example.go deleted file mode 100644 index 68f189f..0000000 --- a/vendor/github.com/GeertJohan/go.rice/example/example.go +++ /dev/null @@ -1,69 +0,0 @@ -package main - -import ( - "encoding/hex" - "fmt" - "log" - "net/http" - "os" - "text/template" - - "github.com/GeertJohan/go.rice" - "github.com/davecgh/go-spew/spew" -) - -func main() { - conf := rice.Config{ - LocateOrder: []rice.LocateMethod{rice.LocateEmbedded, rice.LocateAppended, rice.LocateFS}, - } - box, err := conf.FindBox("example-files") - if err != nil { - log.Fatalf("error opening rice.Box: %s\n", err) - } - // spew.Dump(box) - - contentString, err := box.String("file.txt") - if err != nil { - log.Fatalf("could not read file contents as string: %s\n", err) - } - log.Printf("Read some file contents as string:\n%s\n", contentString) - - contentBytes, err := box.Bytes("file.txt") - if err != nil { - log.Fatalf("could not read file contents as byteSlice: %s\n", err) - } - log.Printf("Read some file contents as byteSlice:\n%s\n", hex.Dump(contentBytes)) - - file, err := box.Open("file.txt") - if err != nil { - log.Fatalf("could not open file: %s\n", err) - } - spew.Dump(file) - - // find/create a rice.Box - templateBox, err := rice.FindBox("example-templates") - if err != nil { - log.Fatal(err) - } - // get file contents as string - templateString, err := templateBox.String("message.tmpl") - if err != nil { - log.Fatal(err) - } - // parse and execute the template - tmplMessage, err := template.New("message").Parse(templateString) - if err != nil { - log.Fatal(err) - } - tmplMessage.Execute(os.Stdout, map[string]string{"Message": "Hello, world!"}) - - http.Handle("/", http.FileServer(box.HTTPBox())) - go func() { - fmt.Println("Serving files on :8080, press ctrl-C to exit") - err := http.ListenAndServe(":8080", nil) - if err != nil { - log.Fatalf("error serving files: %v", err) - } - }() - select {} -} diff --git a/vendor/github.com/GeertJohan/go.rice/file.go b/vendor/github.com/GeertJohan/go.rice/file.go deleted file mode 100644 index 606a188..0000000 --- a/vendor/github.com/GeertJohan/go.rice/file.go +++ /dev/null @@ -1,144 +0,0 @@ -package rice - -import ( - "bytes" - "errors" - "os" - "path/filepath" -) - -// File implements the io.Reader, io.Seeker, io.Closer and http.File interfaces -type File struct { - // File abstracts file methods so the user doesn't see the difference between rice.virtualFile, rice.virtualDir and os.File - // TODO: maybe use internal File interface and four implementations: *os.File, appendedFile, virtualFile, virtualDir - - // real file on disk - realF *os.File - - // when embedded (go) - virtualF *virtualFile - virtualD *virtualDir - - // when appended (zip) - appendedF *appendedFile - appendedFileReader *bytes.Reader - // TODO: is appendedFileReader subject of races? Might need a lock here.. -} - -// Close is like (*os.File).Close() -// Visit http://golang.org/pkg/os/#File.Close for more information -func (f *File) Close() error { - if f.appendedF != nil { - if f.appendedFileReader == nil { - return errors.New("already closed") - } - f.appendedFileReader = nil - return nil - } - if f.virtualF != nil { - return f.virtualF.close() - } - if f.virtualD != nil { - return f.virtualD.close() - } - return f.realF.Close() -} - -// Stat is like (*os.File).Stat() -// Visit http://golang.org/pkg/os/#File.Stat for more information -func (f *File) Stat() (os.FileInfo, error) { - if f.appendedF != nil { - if f.appendedF.dir { - return f.appendedF.dirInfo, nil - } - if f.appendedFileReader == nil { - return nil, errors.New("file is closed") - } - return f.appendedF.zipFile.FileInfo(), nil - } - if f.virtualF != nil { - return f.virtualF.stat() - } - if f.virtualD != nil { - return f.virtualD.stat() - } - return f.realF.Stat() -} - -// Readdir is like (*os.File).Readdir() -// Visit http://golang.org/pkg/os/#File.Readdir for more information -func (f *File) Readdir(count int) ([]os.FileInfo, error) { - if f.appendedF != nil { - if f.appendedF.dir { - fi := make([]os.FileInfo, 0, len(f.appendedF.children)) - for _, childAppendedFile := range f.appendedF.children { - if childAppendedFile.dir { - fi = append(fi, childAppendedFile.dirInfo) - } else { - fi = append(fi, childAppendedFile.zipFile.FileInfo()) - } - } - return fi, nil - } - //++ TODO: is os.ErrInvalid the correct error for Readdir on file? - return nil, os.ErrInvalid - } - if f.virtualF != nil { - return f.virtualF.readdir(count) - } - if f.virtualD != nil { - return f.virtualD.readdir(count) - } - return f.realF.Readdir(count) -} - -// Read is like (*os.File).Read() -// Visit http://golang.org/pkg/os/#File.Read for more information -func (f *File) Read(bts []byte) (int, error) { - if f.appendedF != nil { - if f.appendedFileReader == nil { - return 0, &os.PathError{ - Op: "read", - Path: filepath.Base(f.appendedF.zipFile.Name), - Err: errors.New("file is closed"), - } - } - if f.appendedF.dir { - return 0, &os.PathError{ - Op: "read", - Path: filepath.Base(f.appendedF.zipFile.Name), - Err: errors.New("is a directory"), - } - } - return f.appendedFileReader.Read(bts) - } - if f.virtualF != nil { - return f.virtualF.read(bts) - } - if f.virtualD != nil { - return f.virtualD.read(bts) - } - return f.realF.Read(bts) -} - -// Seek is like (*os.File).Seek() -// Visit http://golang.org/pkg/os/#File.Seek for more information -func (f *File) Seek(offset int64, whence int) (int64, error) { - if f.appendedF != nil { - if f.appendedFileReader == nil { - return 0, &os.PathError{ - Op: "seek", - Path: filepath.Base(f.appendedF.zipFile.Name), - Err: errors.New("file is closed"), - } - } - return f.appendedFileReader.Seek(offset, whence) - } - if f.virtualF != nil { - return f.virtualF.seek(offset, whence) - } - if f.virtualD != nil { - return f.virtualD.seek(offset, whence) - } - return f.realF.Seek(offset, whence) -} diff --git a/vendor/github.com/GeertJohan/go.rice/http.go b/vendor/github.com/GeertJohan/go.rice/http.go deleted file mode 100644 index 3a61f0e..0000000 --- a/vendor/github.com/GeertJohan/go.rice/http.go +++ /dev/null @@ -1,21 +0,0 @@ -package rice - -import ( - "net/http" -) - -// HTTPBox implements http.FileSystem which allows the use of Box with a http.FileServer. -// e.g.: http.Handle("/", http.FileServer(rice.MustFindBox("http-files").HTTPBox())) -type HTTPBox struct { - *Box -} - -// HTTPBox creates a new HTTPBox from an existing Box -func (b *Box) HTTPBox() *HTTPBox { - return &HTTPBox{b} -} - -// Open returns a File using the http.File interface -func (hb *HTTPBox) Open(name string) (http.File, error) { - return hb.Box.Open(name) -} diff --git a/vendor/github.com/GeertJohan/go.rice/rice/append.go b/vendor/github.com/GeertJohan/go.rice/rice/append.go deleted file mode 100644 index 8ab0130..0000000 --- a/vendor/github.com/GeertJohan/go.rice/rice/append.go +++ /dev/null @@ -1,157 +0,0 @@ -package main - -import ( - "archive/zip" - "fmt" - "go/build" - "io" - "os" - "path/filepath" - "strings" - "time" - - zipexe "github.com/daaku/go.zipexe" -) - -func operationAppend(pkgs []*build.Package) { - // create tmp zipfile - tmpZipfileName := filepath.Join(os.TempDir(), fmt.Sprintf("ricebox-%d-%s.zip", time.Now().Unix(), randomString(10))) - verbosef("Will create tmp zipfile: %s\n", tmpZipfileName) - tmpZipfile, err := os.Create(tmpZipfileName) - if err != nil { - fmt.Printf("Error creating tmp zipfile: %s\n", err) - os.Exit(1) - } - defer func() { - tmpZipfile.Close() - os.Remove(tmpZipfileName) - }() - - // find abs path for binary file - binfileName, err := filepath.Abs(flags.Append.Executable) - if err != nil { - fmt.Printf("Error finding absolute path for executable to append: %s\n", err) - os.Exit(1) - } - verbosef("Will append to file: %s\n", binfileName) - - // check that command doesn't already have zip appended - if rd, _ := zipexe.Open(binfileName); rd != nil { - fmt.Printf("Cannot append to already appended executable. Please remove %s and build a fresh one.\n", binfileName) - os.Exit(1) - } - - // open binfile - binfile, err := os.OpenFile(binfileName, os.O_WRONLY, os.ModeAppend) - if err != nil { - fmt.Printf("Error: unable to open executable file: %s\n", err) - os.Exit(1) - } - defer binfile.Close() - - binfileInfo, err := binfile.Stat() - if err != nil { - fmt.Printf("Error: unable to stat executable file: %s\n", err) - os.Exit(1) - } - - // create zip.Writer - zipWriter := zip.NewWriter(tmpZipfile) - - // write the zip offset into the zip data - zipWriter.SetOffset(binfileInfo.Size()) - - for _, pkg := range pkgs { - // find boxes for this command - boxMap := findBoxes(pkg) - - // notify user when no calls to rice.FindBox are made (is this an error and therefore os.Exit(1) ? - if len(boxMap) == 0 { - fmt.Printf("no calls to rice.FindBox() or rice.MustFindBox() found in import path `%s`\n", pkg.ImportPath) - continue - } - - verbosef("\n") - - for boxname := range boxMap { - appendedBoxName := strings.Replace(boxname, `/`, `-`, -1) - - // walk box path's and insert files - boxPath := filepath.Clean(filepath.Join(pkg.Dir, boxname)) - filepath.Walk(boxPath, func(path string, info os.FileInfo, err error) error { - if info == nil { - fmt.Printf("Error: box \"%s\" not found on disk\n", path) - os.Exit(1) - } - // create zipFilename - zipFileName := filepath.Join(appendedBoxName, strings.TrimPrefix(path, boxPath)) - // write directories as empty file with comment "dir" - if info.IsDir() { - _, err := zipWriter.CreateHeader(&zip.FileHeader{ - Name: zipFileName, - Comment: "dir", - }) - if err != nil { - fmt.Printf("Error creating dir in tmp zip: %s\n", err) - os.Exit(1) - } - return nil - } - - // create zipFileWriter - zipFileHeader, err := zip.FileInfoHeader(info) - if err != nil { - fmt.Printf("Error creating zip FileHeader: %v\n", err) - os.Exit(1) - } - zipFileHeader.Name = zipFileName - zipFileWriter, err := zipWriter.CreateHeader(zipFileHeader) - if err != nil { - fmt.Printf("Error creating file in tmp zip: %s\n", err) - os.Exit(1) - } - srcFile, err := os.Open(path) - if err != nil { - fmt.Printf("Error opening file to append: %s\n", err) - os.Exit(1) - } - _, err = io.Copy(zipFileWriter, srcFile) - if err != nil { - fmt.Printf("Error copying file contents to zip: %s\n", err) - os.Exit(1) - } - srcFile.Close() - - return nil - }) - } - } - - err = zipWriter.Close() - if err != nil { - fmt.Printf("Error closing tmp zipfile: %s\n", err) - os.Exit(1) - } - - err = tmpZipfile.Sync() - if err != nil { - fmt.Printf("Error syncing tmp zipfile: %s\n", err) - os.Exit(1) - } - _, err = tmpZipfile.Seek(0, 0) - if err != nil { - fmt.Printf("Error seeking tmp zipfile: %s\n", err) - os.Exit(1) - } - _, err = binfile.Seek(0, 2) - if err != nil { - fmt.Printf("Error seeking bin file: %s\n", err) - os.Exit(1) - } - - _, err = io.Copy(binfile, tmpZipfile) - if err != nil { - fmt.Printf("Error appending zipfile to executable: %s\n", err) - os.Exit(1) - } -} diff --git a/vendor/github.com/GeertJohan/go.rice/rice/clean.go b/vendor/github.com/GeertJohan/go.rice/rice/clean.go deleted file mode 100644 index 6155c06..0000000 --- a/vendor/github.com/GeertJohan/go.rice/rice/clean.go +++ /dev/null @@ -1,33 +0,0 @@ -package main - -import ( - "fmt" - "go/build" - "os" - "path/filepath" - "strings" -) - -func operationClean(pkg *build.Package) { - filepath.Walk(pkg.Dir, func(filename string, info os.FileInfo, err error) error { - if err != nil { - fmt.Printf("error walking pkg dir to clean files: %v\n", err) - os.Exit(1) - } - if info.IsDir() { - return nil - } - verbosef("checking file '%s'\n", filename) - if filepath.Base(filename) == "rice-box.go" || - strings.HasSuffix(filename, ".rice-box.go") || - strings.HasSuffix(filename, ".rice-box.syso") { - err := os.Remove(filename) - if err != nil { - fmt.Printf("error removing file (%s): %s\n", filename, err) - os.Exit(-1) - } - verbosef("removed file '%s'\n", filename) - } - return nil - }) -} diff --git a/vendor/github.com/GeertJohan/go.rice/rice/embed-go.go b/vendor/github.com/GeertJohan/go.rice/rice/embed-go.go deleted file mode 100644 index 3706cca..0000000 --- a/vendor/github.com/GeertJohan/go.rice/rice/embed-go.go +++ /dev/null @@ -1,161 +0,0 @@ -package main - -import ( - "bytes" - "fmt" - "go/build" - "go/format" - "io" - "io/ioutil" - "log" - "os" - "path/filepath" - "strings" -) - -const boxFilename = "rice-box.go" - -func writeBoxesGo(pkg *build.Package, out io.Writer) error { - boxMap := findBoxes(pkg) - - // notify user when no calls to rice.FindBox are made (is this an error and therefore os.Exit(1) ? - if len(boxMap) == 0 { - fmt.Println("no calls to rice.FindBox() found") - return nil - } - - verbosef("\n") - - var boxes []*boxDataType - - for boxname := range boxMap { - // find path and filename for this box - boxPath := filepath.Join(pkg.Dir, boxname) - - // Check to see if the path for the box is a symbolic link. If so, simply - // box what the symbolic link points to. Note: the filepath.Walk function - // will NOT follow any nested symbolic links. This only handles the case - // where the root of the box is a symbolic link. - symPath, serr := os.Readlink(boxPath) - if serr == nil { - boxPath = symPath - } - - // verbose info - verbosef("embedding box '%s' to '%s'\n", boxname, boxFilename) - - // read box metadata - boxInfo, ierr := os.Stat(boxPath) - if ierr != nil { - return fmt.Errorf("Error: unable to access box at %s\n", boxPath) - } - - // create box datastructure (used by template) - box := &boxDataType{ - BoxName: boxname, - UnixNow: boxInfo.ModTime().Unix(), - Files: make([]*fileDataType, 0), - Dirs: make(map[string]*dirDataType), - } - - if !boxInfo.IsDir() { - return fmt.Errorf("Error: Box %s must point to a directory but points to %s instead\n", - boxname, boxPath) - } - - // fill box datastructure with file data - err := filepath.Walk(boxPath, func(path string, info os.FileInfo, err error) error { - if err != nil { - return fmt.Errorf("error walking box: %s\n", err) - } - - filename := strings.TrimPrefix(path, boxPath) - filename = strings.Replace(filename, "\\", "/", -1) - filename = strings.TrimPrefix(filename, "/") - if info.IsDir() { - dirData := &dirDataType{ - Identifier: "dir" + nextIdentifier(), - FileName: filename, - ModTime: info.ModTime().Unix(), - ChildFiles: make([]*fileDataType, 0), - ChildDirs: make([]*dirDataType, 0), - } - verbosef("\tincludes dir: '%s'\n", dirData.FileName) - box.Dirs[dirData.FileName] = dirData - - // add tree entry (skip for root, it'll create a recursion) - if dirData.FileName != "" { - pathParts := strings.Split(dirData.FileName, "/") - parentDir := box.Dirs[strings.Join(pathParts[:len(pathParts)-1], "/")] - parentDir.ChildDirs = append(parentDir.ChildDirs, dirData) - } - } else { - fileData := &fileDataType{ - Identifier: "file" + nextIdentifier(), - FileName: filename, - ModTime: info.ModTime().Unix(), - } - verbosef("\tincludes file: '%s'\n", fileData.FileName) - fileData.Content, err = ioutil.ReadFile(path) - if err != nil { - return fmt.Errorf("error reading file content while walking box: %s\n", err) - } - box.Files = append(box.Files, fileData) - - // add tree entry - pathParts := strings.Split(fileData.FileName, "/") - parentDir := box.Dirs[strings.Join(pathParts[:len(pathParts)-1], "/")] - if parentDir == nil { - return fmt.Errorf("Error: parent of %s is not within the box\n", path) - } - parentDir.ChildFiles = append(parentDir.ChildFiles, fileData) - } - return nil - }) - if err != nil { - return err - } - boxes = append(boxes, box) - - } - - embedSourceUnformated := bytes.NewBuffer(make([]byte, 0)) - - // execute template to buffer - err := tmplEmbeddedBox.Execute( - embedSourceUnformated, - embedFileDataType{pkg.Name, boxes}, - ) - if err != nil { - return fmt.Errorf("error writing embedded box to file (template execute): %s\n", err) - } - - // format the source code - embedSource, err := format.Source(embedSourceUnformated.Bytes()) - if err != nil { - return fmt.Errorf("error formatting embedSource: %s\n", err) - } - - // write source to file - _, err = io.Copy(out, bytes.NewBuffer(embedSource)) - if err != nil { - return fmt.Errorf("error writing embedSource to file: %s\n", err) - } - return nil -} - -func operationEmbedGo(pkg *build.Package) { - // create go file for box - boxFile, err := os.Create(filepath.Join(pkg.Dir, boxFilename)) - if err != nil { - log.Printf("error creating embedded box file: %s\n", err) - os.Exit(1) - } - defer boxFile.Close() - - err = writeBoxesGo(pkg, boxFile) - if err != nil { - log.Printf("error creating embedded box file: %s\n", err) - os.Exit(1) - } -} diff --git a/vendor/github.com/GeertJohan/go.rice/rice/embed-go_test.go b/vendor/github.com/GeertJohan/go.rice/rice/embed-go_test.go deleted file mode 100644 index b75f060..0000000 --- a/vendor/github.com/GeertJohan/go.rice/rice/embed-go_test.go +++ /dev/null @@ -1,680 +0,0 @@ -package main - -import ( - "bytes" - "fmt" - "go/ast" - "go/parser" - "go/token" - "path" - "path/filepath" - "strconv" - "strings" - "testing" -) - -type registeredDir struct { - Filename string - ModTime int - ChildFiles []*registeredFile - ChildDirs []*registeredDir -} - -type registeredFile struct { - Filename string - ModTime int - Content string -} - -type registeredBox struct { - Name string - Time int - // key is path - Dirs map[string]*registeredDir - // key is path - Files map[string]*registeredFile -} - -// isSimpleSelector returns true if expr is pkgName.ident -func isSimpleSelector(pkgName, ident string, expr ast.Expr) bool { - if sel, ok := expr.(*ast.SelectorExpr); ok { - if pkgIdent, ok := sel.X.(*ast.Ident); ok && pkgIdent.Name == pkgName && sel.Sel != nil && sel.Sel.Name == ident { - return true - } - } - return false -} - -func isIdent(ident string, expr ast.Expr) bool { - if expr, ok := expr.(*ast.Ident); ok && expr.Name == ident { - return true - } - return false -} - -func getIdentName(expr ast.Expr) (string, bool) { - if expr, ok := expr.(*ast.Ident); ok { - return expr.Name, true - } - return "", false -} - -func getKey(expr *ast.KeyValueExpr) string { - if ident, ok := expr.Key.(*ast.Ident); ok { - return ident.Name - } - return "" -} - -// parseModTime parses a time.Unix call, and returns the unix time. -func parseModTime(expr ast.Expr) (int, error) { - if expr, ok := expr.(*ast.CallExpr); ok { - if !isSimpleSelector("time", "Unix", expr.Fun) { - return 0, fmt.Errorf("ModTime is not time.Unix: %#v", expr.Fun) - } - if len(expr.Args) == 0 { - return 0, fmt.Errorf("not enough args to time.Unix") - } - arg0 := expr.Args[0] - if lit, ok := arg0.(*ast.BasicLit); ok && lit.Kind == token.INT { - return strconv.Atoi(lit.Value) - } - } - return 0, fmt.Errorf("not time.Unix: %#v", expr) -} - -func parseString(expr ast.Expr) (string, error) { - if expr, ok := expr.(*ast.CallExpr); ok && isIdent("string", expr.Fun) && len(expr.Args) == 1 { - return parseString(expr.Args[0]) - } - if lit, ok := expr.(*ast.BasicLit); ok && lit.Kind == token.STRING { - return strconv.Unquote(lit.Value) - } - return "", fmt.Errorf("not string: %#v", expr) -} - -// parseDir parses an embedded.EmbeddedDir literal. -// It can be either a variable name or a composite literal. -// Returns nil if the literal is not embedded.EmbeddedDir. -func parseDir(expr ast.Expr, dirs map[string]*registeredDir, files map[string]*registeredFile) (*registeredDir, []error) { - - if varName, ok := getIdentName(expr); ok { - dir, ok := dirs[varName] - if !ok { - return nil, []error{fmt.Errorf("unknown variable %v", varName)} - } - return dir, nil - } - - lit, ok := expr.(*ast.CompositeLit) - if !ok { - return nil, []error{fmt.Errorf("dir is not a composite literal: %#v", expr)} - } - - var errors []error - if !isSimpleSelector("embedded", "EmbeddedDir", lit.Type) { - return nil, nil - } - ret := ®isteredDir{} - for _, el := range lit.Elts { - if el, ok := el.(*ast.KeyValueExpr); ok { - key := getKey(el) - if key == "" { - continue - } - switch key { - case "DirModTime": - var err error - ret.ModTime, err = parseModTime(el.Value) - if err != nil { - errors = append(errors, fmt.Errorf("DirModTime %s", err)) - } - case "Filename": - var err error - ret.Filename, err = parseString(el.Value) - if err != nil { - errors = append(errors, fmt.Errorf("Filename %s", err)) - } - case "ChildDirs": - var errors2 []error - ret.ChildDirs, errors2 = parseDirsSlice(el.Value, dirs, files) - errors = append(errors, errors2...) - case "ChildFiles": - var errors2 []error - ret.ChildFiles, errors2 = parseFilesSlice(el.Value, files) - errors = append(errors, errors2...) - default: - errors = append(errors, fmt.Errorf("Unknown field: %v: %#v", key, el.Value)) - } - } - } - return ret, errors -} - -// parseFile parses an embedded.EmbeddedFile literal. -// It can be either a variable name or a composite literal. -// Returns nil if the literal is not embedded.EmbeddedFile. -func parseFile(expr ast.Expr, files map[string]*registeredFile) (*registeredFile, []error) { - if varName, ok := getIdentName(expr); ok { - file, ok := files[varName] - if !ok { - return nil, []error{fmt.Errorf("unknown variable %v", varName)} - } - return file, nil - } - - lit, ok := expr.(*ast.CompositeLit) - if !ok { - return nil, []error{fmt.Errorf("file is not a composite literal: %#v", expr)} - } - - var errors []error - if !isSimpleSelector("embedded", "EmbeddedFile", lit.Type) { - return nil, nil - } - ret := ®isteredFile{} - for _, el := range lit.Elts { - if el, ok := el.(*ast.KeyValueExpr); ok { - key := getKey(el) - if key == "" { - continue - } - switch key { - case "FileModTime": - var err error - ret.ModTime, err = parseModTime(el.Value) - if err != nil { - errors = append(errors, fmt.Errorf("DirModTime %s", err)) - } - case "Filename": - var err error - ret.Filename, err = parseString(el.Value) - if err != nil { - errors = append(errors, fmt.Errorf("Filename %s", err)) - } - case "Content": - var err error - ret.Content, err = parseString(el.Value) - if err != nil { - errors = append(errors, fmt.Errorf("Content %s", err)) - } - default: - errors = append(errors, fmt.Errorf("Unknown field: %v: %#v", key, el.Value)) - } - } - } - return ret, errors -} - -func parseRegistration(lit *ast.CompositeLit, dirs map[string]*registeredDir, files map[string]*registeredFile) (*registeredBox, []error) { - var errors []error - if !isSimpleSelector("embedded", "EmbeddedBox", lit.Type) { - return nil, nil - } - ret := ®isteredBox{ - Dirs: make(map[string]*registeredDir), - Files: make(map[string]*registeredFile), - } - for _, el := range lit.Elts { - if el, ok := el.(*ast.KeyValueExpr); ok { - key := getKey(el) - if key == "" { - continue - } - switch key { - case "Time": - var err error - ret.Time, err = parseModTime(el.Value) - if err != nil { - errors = append(errors, fmt.Errorf("Time %s", err)) - } - case "Name": - var err error - ret.Name, err = parseString(el.Value) - if err != nil { - errors = append(errors, fmt.Errorf("Name %s", err)) - } - case "Dirs": - var errors2 []error - ret.Dirs, errors2 = parseDirsMap(el.Value, dirs, files) - errors = append(errors, errors2...) - case "Files": - var errors2 []error - ret.Files, errors2 = parseFilesMap(el.Value, files) - errors = append(errors, errors2...) - default: - errors = append(errors, fmt.Errorf("Unknown field: %v: %#v", key, el.Value)) - } - } - } - return ret, errors -} - -func parseDirsSlice(expr ast.Expr, dirs map[string]*registeredDir, files map[string]*registeredFile) (childDirs []*registeredDir, errors []error) { - valid := false - lit, ok := expr.(*ast.CompositeLit) - if ok { - if arrType, ok := lit.Type.(*ast.ArrayType); ok { - if star, ok := arrType.Elt.(*ast.StarExpr); ok { - if isSimpleSelector("embedded", "EmbeddedDir", star.X) { - valid = true - } - } - } - } - - if !valid { - return nil, []error{fmt.Errorf("not a []*embedded.EmbeddedDir: %#v", expr)} - } - for _, el := range lit.Elts { - child, childErrors := parseDir(el, dirs, files) - errors = append(errors, childErrors...) - childDirs = append(childDirs, child) - } - return -} - -func parseFilesSlice(expr ast.Expr, files map[string]*registeredFile) (childFiles []*registeredFile, errors []error) { - valid := false - lit, ok := expr.(*ast.CompositeLit) - if ok { - if arrType, ok := lit.Type.(*ast.ArrayType); ok { - if star, ok := arrType.Elt.(*ast.StarExpr); ok { - if isSimpleSelector("embedded", "EmbeddedFile", star