diff options
author | Michael Muré <batolettre@gmail.com> | 2019-05-22 20:53:53 +0200 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2019-05-22 20:53:53 +0200 |
commit | 485ca5900486b7fc3ea71cbcbb39b87272ae09fd (patch) | |
tree | 92551be8e01130542f969d06282abfc4a1c43629 /vendor/github.com/shurcooL | |
parent | e781d6c7fe7dba2fc526c2049aa188c9988e1cf4 (diff) | |
download | git-bug-485ca5900486b7fc3ea71cbcbb39b87272ae09fd.tar.gz |
vendor: update dependencies
Diffstat (limited to 'vendor/github.com/shurcooL')
-rw-r--r-- | vendor/github.com/shurcooL/vfsgen/LICENSE | 21 | ||||
-rw-r--r-- | vendor/github.com/shurcooL/vfsgen/README.md | 31 | ||||
-rw-r--r-- | vendor/github.com/shurcooL/vfsgen/generator.go | 7 |
3 files changed, 51 insertions, 8 deletions
diff --git a/vendor/github.com/shurcooL/vfsgen/LICENSE b/vendor/github.com/shurcooL/vfsgen/LICENSE new file mode 100644 index 00000000..c35c17af --- /dev/null +++ b/vendor/github.com/shurcooL/vfsgen/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2015 Dmitri Shuralyov + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/vendor/github.com/shurcooL/vfsgen/README.md b/vendor/github.com/shurcooL/vfsgen/README.md index a7781cb1..659a0a03 100644 --- a/vendor/github.com/shurcooL/vfsgen/README.md +++ b/vendor/github.com/shurcooL/vfsgen/README.md @@ -26,22 +26,43 @@ go get -u github.com/shurcooL/vfsgen Usage ----- -This code will generate an assets_vfsdata.go file with `var assets http.FileSystem = ...` that statically implements the contents of "assets" directory. +Package `vfsgen` is a Go code generator library. It has a `Generate` function that takes an input filesystem (as a [`http.FileSystem`](https://godoc.org/net/http#FileSystem) type), and generates a Go code file that statically implements the contents of the input filesystem. + +For example, we can use [`http.Dir`](https://godoc.org/net/http#Dir) as a `http.FileSystem` implementation that uses the contents of the `/path/to/assets` directory: ```Go -var fs http.FileSystem = http.Dir("assets") +var fs http.FileSystem = http.Dir("/path/to/assets") +``` +Now, when you execute the following code: + +```Go err := vfsgen.Generate(fs, vfsgen.Options{}) if err != nil { log.Fatalln(err) } ``` +An assets_vfsdata.go file will be generated in the current directory: + +```Go +// Code generated by vfsgen; DO NOT EDIT. + +package main + +import ... + +// assets statically implements the virtual filesystem provided to vfsgen.Generate. +var assets http.FileSystem = ... +``` + Then, in your program, you can use `assets` as any other [`http.FileSystem`](https://godoc.org/net/http#FileSystem), for example: ```Go file, err := assets.Open("/some/file.txt") -if err != nil { ... } +if err != nil { + return err +} defer file.Close() ``` @@ -49,6 +70,8 @@ defer file.Close() http.Handle("/assets/", http.FileServer(assets)) ``` +`vfsgen` can be more useful when combined with build tags and go generate directives. This is described below. + ### `go generate` Usage vfsgen is great to use with go generate directives. The code invoking `vfsgen.Generate` can go in an assets_generate.go file, which can then be invoked via "//go:generate go run assets_generate.go". The input virtual filesystem can read directly from disk, or it can be more involved. @@ -175,4 +198,4 @@ This package was originally based on the excellent work by [@jteeuwen](https://g License ------- -- [MIT License](https://opensource.org/licenses/mit-license.php) +- [MIT License](LICENSE) diff --git a/vendor/github.com/shurcooL/vfsgen/generator.go b/vendor/github.com/shurcooL/vfsgen/generator.go index a95c81cb..5782693e 100644 --- a/vendor/github.com/shurcooL/vfsgen/generator.go +++ b/vendor/github.com/shurcooL/vfsgen/generator.go @@ -7,7 +7,6 @@ import ( "fmt" "io" "io/ioutil" - "log" "net/http" "os" pathpkg "path" @@ -83,8 +82,8 @@ type dirInfo struct { func findAndWriteFiles(buf *bytes.Buffer, fs http.FileSystem, toc *toc) error { walkFn := func(path string, fi os.FileInfo, r io.ReadSeeker, err error) error { if err != nil { - log.Printf("can't stat file %q: %v\n", path, err) - return nil + // Consider all errors reading the input filesystem as fatal. + return err } switch fi.IsDir() { @@ -301,7 +300,7 @@ func (fs vfsgen۰FS) Open(path string) (http.File, error) { } return &vfsgen۰CompressedFile{ vfsgen۰CompressedFileInfo: f, - gr: gr, + gr: gr, }, nil{{end}}{{if .HasFile}} case *vfsgen۰FileInfo: return &vfsgen۰File{ |