aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/GeertJohan
diff options
context:
space:
mode:
authorChristine Dodrill <me@christine.website>2017-12-13 10:43:58 -0800
committerChristine Dodrill <me@christine.website>2017-12-13 11:42:37 -0800
commit3a21ef192628f6952eaa981bcdf718a35a4b43c7 (patch)
tree9c88a3ddc57ab5014f436ec2c08c96280872632e /vendor/github.com/GeertJohan
parent3b4b6cede9bc30008b0f40989a1564b26e64fd05 (diff)
downloadxesite-3a21ef192628f6952eaa981bcdf718a35a4b43c7.tar.xz
xesite-3a21ef192628f6952eaa981bcdf718a35a4b43c7.zip
convert to go buildpack
Diffstat (limited to 'vendor/github.com/GeertJohan')
-rw-r--r--vendor/github.com/GeertJohan/go.rice/.gitignore8
-rw-r--r--vendor/github.com/GeertJohan/go.rice/.travis.yml19
-rw-r--r--vendor/github.com/GeertJohan/go.rice/AUTHORS4
-rw-r--r--vendor/github.com/GeertJohan/go.rice/LICENSE22
-rw-r--r--vendor/github.com/GeertJohan/go.rice/README.md151
-rw-r--r--vendor/github.com/GeertJohan/go.rice/config_test.go136
-rw-r--r--vendor/github.com/GeertJohan/go.rice/example/example-files/file.txt2
-rw-r--r--vendor/github.com/GeertJohan/go.rice/example/example-files/img/doge.jpgbin0 -> 53549 bytes
-rw-r--r--vendor/github.com/GeertJohan/go.rice/example/example-templates/message.tmpl1
-rw-r--r--vendor/github.com/GeertJohan/go.rice/example/example.go69
-rw-r--r--vendor/github.com/GeertJohan/go.rice/rice/append.go157
-rw-r--r--vendor/github.com/GeertJohan/go.rice/rice/clean.go33
-rw-r--r--vendor/github.com/GeertJohan/go.rice/rice/embed-go.go161
-rw-r--r--vendor/github.com/GeertJohan/go.rice/rice/embed-go_test.go680
-rw-r--r--vendor/github.com/GeertJohan/go.rice/rice/embed-syso.go204
-rw-r--r--vendor/github.com/GeertJohan/go.rice/rice/find.go150
-rw-r--r--vendor/github.com/GeertJohan/go.rice/rice/find_test.go302
-rw-r--r--vendor/github.com/GeertJohan/go.rice/rice/flags.go80
-rw-r--r--vendor/github.com/GeertJohan/go.rice/rice/identifier.go14
-rw-r--r--vendor/github.com/GeertJohan/go.rice/rice/main.go68
-rw-r--r--vendor/github.com/GeertJohan/go.rice/rice/templates.go98
-rw-r--r--vendor/github.com/GeertJohan/go.rice/rice/util.go22
-rw-r--r--vendor/github.com/GeertJohan/go.rice/rice/writecoff.go42
23 files changed, 2423 insertions, 0 deletions
diff --git a/vendor/github.com/GeertJohan/go.rice/.gitignore b/vendor/github.com/GeertJohan/go.rice/.gitignore
new file mode 100644
index 0000000..a3c9819
--- /dev/null
+++ b/vendor/github.com/GeertJohan/go.rice/.gitignore
@@ -0,0 +1,8 @@
+/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
new file mode 100644
index 0000000..b4840a1
--- /dev/null
+++ b/vendor/github.com/GeertJohan/go.rice/.travis.yml
@@ -0,0 +1,19 @@
+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
new file mode 100644
index 0000000..20ff8ba
--- /dev/null
+++ b/vendor/github.com/GeertJohan/go.rice/AUTHORS
@@ -0,0 +1,4 @@
+Geert-Johan Riemer <geertjohan@geertjohan.net>
+Paul Maddox <paul.maddox@gmail.com>
+Vincent Petithory <vincent.petithory@gmail.com>
+
diff --git a/vendor/github.com/GeertJohan/go.rice/LICENSE b/vendor/github.com/GeertJohan/go.rice/LICENSE
new file mode 100644
index 0000000..8b4409d
--- /dev/null
+++ b/vendor/github.com/GeertJohan/go.rice/LICENSE
@@ -0,0 +1,22 @@
+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
new file mode 100644
index 0000000..836e671
--- /dev/null
+++ b/vendor/github.com/GeertJohan/go.rice/README.md
@@ -0,0 +1,151 @@
+## 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/config_test.go b/vendor/github.com/GeertJohan/go.rice/config_test.go
new file mode 100644
index 0000000..b54296b
--- /dev/null
+++ b/vendor/github.com/GeertJohan/go.rice/config_test.go
@@ -0,0 +1,136 @@
+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/example/example-files/file.txt b/vendor/github.com/GeertJohan/go.rice/example/example-files/file.txt
new file mode 100644
index 0000000..3154578
--- /dev/null
+++ b/vendor/github.com/GeertJohan/go.rice/example/example-files/file.txt
@@ -0,0 +1,2 @@
+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
new file mode 100644
index 0000000..6660dc9
--- /dev/null
+++ b/vendor/github.com/GeertJohan/go.rice/example/example-files/img/doge.jpg
Binary files 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
new file mode 100644
index 0000000..4b7638d
--- /dev/null
+++ b/vendor/github.com/GeertJohan/go.rice/example/example-templates/message.tmpl
@@ -0,0 +1 @@
+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
new file mode 100644
index 0000000..68f189f
--- /dev/null
+++ b/vendor/github.com/GeertJohan/go.rice/example/example.go
@@ -0,0 +1,69 @@
+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/rice/append.go b/vendor/github.com/GeertJohan/go.rice/rice/append.go
new file mode 100644
index 0000000..8ab0130
--- /dev/null
+++ b/vendor/github.com/GeertJohan/go.rice/rice/append.go
@@ -0,0 +1,157 @@
+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
new file mode 100644
index 0000000..6155c06
--- /dev/null
+++ b/vendor/github.com/GeertJohan/go.rice/rice/clean.go
@@ -0,0 +1,33 @@
+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
new file mode 100644
index 0000000..3706cca
--- /dev/null
+++ b/vendor/github.com/GeertJohan/go.rice/rice/embed-go.go
@@ -0,0 +1,161 @@
+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("erro