diff options
| author | Christine Dodrill <me@christine.website> | 2018-07-01 20:38:18 +0000 |
|---|---|---|
| committer | Christine Dodrill <me@christine.website> | 2018-07-01 20:38:18 +0000 |
| commit | 6197f455f695eb959a932e15dc417c1b50a2255b (patch) | |
| tree | eb90c08ea8e688894b033668587635c6e350f13d /vendor/github.com/GeertJohan | |
| parent | b0e0b108231f9b71eebe68d8e9b99ca2846b4534 (diff) | |
| download | xesite-6197f455f695eb959a932e15dc417c1b50a2255b.tar.xz xesite-6197f455f695eb959a932e15dc417c1b50a2255b.zip | |
vgo
Diffstat (limited to 'vendor/github.com/GeertJohan')
34 files changed, 0 insertions, 3669 deletions
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 <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 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 - -[](https://travis-ci.org/GeertJohan/go.rice) -[](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/G |
