You've already forked postgres_exporter
mirror of
https://github.com/prometheus-community/postgres_exporter.git
synced 2025-08-08 04:42:07 +03:00
Refactor repository layout and convert build system to Mage.
This commit implements a massive refactor of the repository, and moves the build system over to use Mage (magefile.org) which should allow seamless building across multiple platforms.
This commit is contained in:
79
tools/vendor/github.com/tmthrgd/go-bindata/CONTRIBUTING.md
generated
vendored
Normal file
79
tools/vendor/github.com/tmthrgd/go-bindata/CONTRIBUTING.md
generated
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
## Contribution guidelines.
|
||||
|
||||
So you wish to contribute to this project? Fantastic!
|
||||
Here are a few guidelines to help you do this in a
|
||||
streamlined fashion.
|
||||
|
||||
|
||||
## Bug reports
|
||||
|
||||
When supplying a bug report, please consider the following guidelines.
|
||||
These serve to make it easier for us to address the issue and find a solution.
|
||||
Most of these are pretty self-evident, but sometimes it is still necessary
|
||||
to reiterate them.
|
||||
|
||||
* Be clear in the way you express the problem. Use simple language and
|
||||
just enough of it to clearly define the issue. Not everyone is a native
|
||||
English speaker. And while most can handle themselves pretty well,
|
||||
it helps to stay away from more esoteric vocabulary.
|
||||
|
||||
Be patient with non-native English speakers. If their bug reports
|
||||
or comments are hard to understand, just ask for clarification.
|
||||
Do not start guessing at their meaning, as this may just lead to
|
||||
more confusion and misunderstandings.
|
||||
* Clearly define any information which is relevant to the problem.
|
||||
This includes library versions, operating system and any other
|
||||
external dependencies which may be needed.
|
||||
* Where applicable, provide a step-by-step listing of the way to
|
||||
reproduce the problem. Make sure this is the simplest possible
|
||||
way to do so. Omit any and all unneccesary steps, because they may
|
||||
just complicate our understanding of the real problem.
|
||||
If need be, create a whole new code project on your local machine,
|
||||
which specifically tries to create the problem you are running into;
|
||||
nothing more, nothing less.
|
||||
|
||||
Include this program in the bug report. It often suffices to paste
|
||||
the code in a [Gist](https://gist.github.com) or on the
|
||||
[Go playground](http://play.golang.org).
|
||||
* If possible, provide us with a listing of the steps you have already
|
||||
undertaken to solve the problem. This can save us a great deal of
|
||||
wasted time, trying out solutions you have already covered.
|
||||
|
||||
|
||||
## Pull requests
|
||||
|
||||
Bug reports are great. Supplying fixes to bugs is even better.
|
||||
When submitting a pull request, the following guidelines are
|
||||
good to keep in mind:
|
||||
|
||||
* `go fmt`: **Always** run your code through `go fmt`, before
|
||||
committing it. Code has to be readable by many different
|
||||
people. And the only way this will be as painless as possible,
|
||||
is if we all stick to the same code style.
|
||||
|
||||
Some of our projects may have automated build-servers hooked up
|
||||
to commit hooks. These will vet any submitted code and determine
|
||||
if it meets a set of properties. One of which is code formatting.
|
||||
These servers will outright deny a submission which has not been
|
||||
run through `go fmt`, even if the code itself is correct.
|
||||
|
||||
We try to maintain a zero-tolerance policy on this matter,
|
||||
because consistently formatted code makes life a great deal
|
||||
easier for everyone involved.
|
||||
* Commit log messages: When committing changes, do so often and
|
||||
clearly -- Even if you have changed only 1 character in a code
|
||||
comment. This means that commit log messages should clearly state
|
||||
exactly what the change does and why. If it fixes a known issue,
|
||||
then mention the issue number in the commit log. E.g.:
|
||||
|
||||
> Fixes return value for `foo/boo.Baz()` to be consistent with
|
||||
> the rest of the API. This addresses issue #32
|
||||
|
||||
Do not pile a lot of unrelated changes into a single commit.
|
||||
Pick and choose only those changes for a single commit, which are
|
||||
directly related. We would much rather see a hundred commits
|
||||
saying nothing but `"Runs go fmt"` in between any real fixes
|
||||
than have these style changes embedded in those real fixes.
|
||||
It creates a lot of noise when trying to review code.
|
||||
|
||||
|
54
tools/vendor/github.com/tmthrgd/go-bindata/LICENSE
generated
vendored
Normal file
54
tools/vendor/github.com/tmthrgd/go-bindata/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
Copyright (c) 2017, Tom Thorogood.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* 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.
|
||||
* Neither the name of the Tom Thorogood nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
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 HOLDERS 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.
|
||||
|
||||
---- Portions of the source code are also covered by the following license: ----
|
||||
|
||||
Copyright (c) 2009 The Go Authors. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* 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.
|
||||
* Neither the name of Google Inc. nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
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.
|
189
tools/vendor/github.com/tmthrgd/go-bindata/README.md
generated
vendored
Normal file
189
tools/vendor/github.com/tmthrgd/go-bindata/README.md
generated
vendored
Normal file
@@ -0,0 +1,189 @@
|
||||
# go-bindata (forked by tmthrgd)
|
||||
|
||||
[](https://godoc.org/github.com/tmthrgd/go-bindata)
|
||||
[](https://travis-ci.org/tmthrgd/go-bindata)
|
||||
[](https://goreportcard.com/report/github.com/tmthrgd/go-bindata)
|
||||
|
||||
This is a rewrite of go-bindata that started life as fork of a fork. It
|
||||
was forked by [lestrrat](https://github.com/lestrrat/go-bindata) as
|
||||
[jteeuwen](https://github.com/jteeuwen/go-bindata) seemed to have
|
||||
abandoned the project.
|
||||
|
||||
Since that fork, go-bindata has been
|
||||
[largely rewritten](https://github.com/tmthrgd/go-bindata/compare/3adb6a8b66f07a123c3d44e8f6c7e78bbdd029c2...master)
|
||||
and has become a standalone project. While the generated code has changed,
|
||||
the generated API remains backwards compatible. The
|
||||
[package API](https://godoc.org/github.com/tmthrgd/go-bindata) is not
|
||||
backwards compatible. The CLI remains backwards compatible, but may not be
|
||||
as feature complete as the package API.
|
||||
|
||||
The suggested way of using go-bindata is from a single .go file with an
|
||||
ignore build tag (`// +build ignore`) run with
|
||||
`//go:generate go run path/to/generate.go`. (See
|
||||
[issue #2](https://github.com/tmthrgd/go-bindata/issues/2#issuecomment-290957538)
|
||||
for reference).
|
||||
|
||||
*Nota bene*: Most of the README that follows has not been updated to match
|
||||
the changes made since rewriting go-bindata and likely does not accurately
|
||||
represent the state of go-bindata.
|
||||
|
||||
## bindata
|
||||
|
||||
This package converts any file into manageable Go source code. Useful for
|
||||
embedding binary data into a go program. The file data is optionally gzip
|
||||
compressed before being converted to a raw byte slice.
|
||||
|
||||
### Installation
|
||||
|
||||
To install the library, use the following:
|
||||
|
||||
go get -u github.com/tmthrgd/go-bindata/...
|
||||
|
||||
### Accessing an asset
|
||||
|
||||
To access asset data, we use the `Asset(string) ([]byte, error)` function which
|
||||
is included in the generated output.
|
||||
|
||||
data, err := Asset("pub/style/foo.css")
|
||||
if err != nil {
|
||||
// Asset was not found.
|
||||
}
|
||||
|
||||
// use asset data
|
||||
|
||||
|
||||
### Debug vs Release builds
|
||||
|
||||
When invoking the program with the `-debug` flag, the generated code does
|
||||
not actually include the asset data. Instead, it generates function stubs
|
||||
which load the data from the original file on disk. The asset API remains
|
||||
identical between debug and release builds, so your code will not have to
|
||||
change.
|
||||
|
||||
This is useful during development when you expect the assets to change often.
|
||||
The host application using these assets uses the same API in both cases and
|
||||
will not have to care where the actual data comes from.
|
||||
|
||||
An example is a Go webserver with some embedded, static web content like
|
||||
HTML, JS and CSS files. While developing it, you do not want to rebuild the
|
||||
whole server and restart it every time you make a change to a bit of
|
||||
javascript. You just want to build and launch the server once. Then just press
|
||||
refresh in the browser to see those changes. Embedding the assets with the
|
||||
`debug` flag allows you to do just that. When you are finished developing and
|
||||
ready for deployment, just re-invoke `go-bindata` without the `-debug` flag.
|
||||
It will now embed the latest version of the assets.
|
||||
|
||||
|
||||
### Lower memory footprint
|
||||
|
||||
Using the `-nomemcopy` flag, will alter the way the output file is generated.
|
||||
It will employ a hack that allows us to read the file data directly from
|
||||
the compiled program's `.rodata` section. This ensures that when we
|
||||
call our generated function, we omit unnecessary memcopies.
|
||||
|
||||
The downside of this, is that it requires dependencies on the `reflect` and
|
||||
`unsafe` packages. These may be restricted on platforms like AppEngine and
|
||||
thus prevent you from using this mode.
|
||||
|
||||
Another disadvantage is that the byte slice we create, is strictly read-only.
|
||||
For most use-cases this is not a problem, but if you ever try to alter the
|
||||
returned byte slice, a runtime panic is thrown. Use this mode only on target
|
||||
platforms where memory constraints are an issue.
|
||||
|
||||
The default behaviour is to use the old code generation method. This
|
||||
prevents the two previously mentioned issues, but will employ at least one
|
||||
extra memcopy and thus increase memory requirements.
|
||||
|
||||
For instance, consider the following two examples:
|
||||
|
||||
This would be the default mode, using an extra memcopy but gives a safe
|
||||
implementation without dependencies on `reflect` and `unsafe`:
|
||||
|
||||
```go
|
||||
func myfile() []byte {
|
||||
return []byte{0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a}
|
||||
}
|
||||
```
|
||||
|
||||
Here is the same functionality, but uses the `.rodata` hack.
|
||||
The byte slice returned from this example can not be written to without
|
||||
generating a runtime error.
|
||||
|
||||
```go
|
||||
var _myfile = "\x89\x50\x4e\x47\x0d\x0a\x1a"
|
||||
|
||||
func myfile() []byte {
|
||||
var empty [0]byte
|
||||
sx := (*reflect.StringHeader)(unsafe.Pointer(&_myfile))
|
||||
b := empty[:]
|
||||
bx := (*reflect.SliceHeader)(unsafe.Pointer(&b))
|
||||
bx.Data = sx.Data
|
||||
bx.Len = len(_myfile)
|
||||
bx.Cap = bx.Len
|
||||
return b
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
### Optional compression
|
||||
|
||||
When the `-nocompress` flag is given, the supplied resource is *not* GZIP
|
||||
compressed before being turned into Go code. The data should still be accessed
|
||||
through a function call, so nothing changes in the usage of the generated file.
|
||||
|
||||
This feature is useful if you do not care for compression, or the supplied
|
||||
resource is already compressed. Doing it again would not add any value and may
|
||||
even increase the size of the data.
|
||||
|
||||
The default behaviour of the program is to use compression.
|
||||
|
||||
|
||||
### Path prefix stripping
|
||||
|
||||
The keys used in the `_bindata` map, are the same as the input file name
|
||||
passed to `go-bindata`. This includes the path. In most cases, this is not
|
||||
desirable, as it puts potentially sensitive information in your code base.
|
||||
For this purpose, the tool supplies another command line flag `-prefix`.
|
||||
This accepts a portion of a path name, which should be stripped off from
|
||||
the map keys and function names.
|
||||
|
||||
For example, running without the `-prefix` flag, we get:
|
||||
|
||||
$ go-bindata /path/to/templates/
|
||||
|
||||
_bindata["/path/to/templates/foo.html"] = path_to_templates_foo_html
|
||||
|
||||
Running with the `-prefix` flag, we get:
|
||||
|
||||
$ go-bindata -prefix "/path/to/" /path/to/templates/
|
||||
|
||||
_bindata["templates/foo.html"] = templates_foo_html
|
||||
|
||||
|
||||
### Build tags
|
||||
|
||||
With the optional `-tags` flag, you can specify any go build tags that
|
||||
must be fulfilled for the output file to be included in a build. This
|
||||
is useful when including binary data in multiple formats, where the desired
|
||||
format is specified at build time with the appropriate tags.
|
||||
|
||||
The tags are appended to a `// +build` line in the beginning of the output file
|
||||
and must follow the build tags syntax specified by the go tool.
|
||||
|
||||
## Testing
|
||||
|
||||
To execute the test case, run the following commands:
|
||||
|
||||
go get -t -u github.com/tmthrgd/go-bindata
|
||||
go test github.com/tmthrgd/go-bindata
|
||||
|
||||
### Test corpus
|
||||
|
||||
To generate the corpus-sha256sums needed for travis, run the following commands:
|
||||
|
||||
[ -d .testcorpus ] && rm -r .testcorpus
|
||||
go test -run TestCorpus -randtests 50 -corpus .testcorpus -gencorpus .
|
||||
cd .testcorpus && sha256sum * > ../corpus-sha256sums; cd ..
|
||||
|
||||
This must be done every time the generated code changes, but can be skipped while working
|
||||
on a pull request until it is ready to merge.
|
22
tools/vendor/github.com/tmthrgd/go-bindata/base32_compat.go
generated
vendored
Normal file
22
tools/vendor/github.com/tmthrgd/go-bindata/base32_compat.go
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
// Copyright 2017 Tom Thorogood. All rights reserved.
|
||||
// Use of this source code is governed by a Modified
|
||||
// BSD License that can be found in the LICENSE file.
|
||||
|
||||
// +build !go1.9
|
||||
|
||||
package bindata
|
||||
|
||||
import (
|
||||
"encoding/base32"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var base32Enc = base32EncodingCompat{
|
||||
base32.NewEncoding("abcdefghijklmnopqrstuvwxyz234567"),
|
||||
}
|
||||
|
||||
type base32EncodingCompat struct{ *base32.Encoding }
|
||||
|
||||
func (enc base32EncodingCompat) EncodeToString(src []byte) string {
|
||||
return strings.TrimSuffix(enc.Encoding.EncodeToString(src), "=")
|
||||
}
|
11
tools/vendor/github.com/tmthrgd/go-bindata/base32_go19.go
generated
vendored
Normal file
11
tools/vendor/github.com/tmthrgd/go-bindata/base32_go19.go
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
// Copyright 2017 Tom Thorogood. All rights reserved.
|
||||
// Use of this source code is governed by a Modified
|
||||
// BSD License that can be found in the LICENSE file.
|
||||
|
||||
// +build go1.9
|
||||
|
||||
package bindata
|
||||
|
||||
import "encoding/base32"
|
||||
|
||||
var base32Enc = base32.NewEncoding("abcdefghijklmnopqrstuvwxyz234567").WithPadding(base32.NoPadding)
|
49
tools/vendor/github.com/tmthrgd/go-bindata/buffers.go
generated
vendored
Normal file
49
tools/vendor/github.com/tmthrgd/go-bindata/buffers.go
generated
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
// Copyright 2017 Tom Thorogood. All rights reserved.
|
||||
// Use of this source code is governed by a Modified
|
||||
// BSD License that can be found in the LICENSE file.
|
||||
|
||||
package bindata
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io"
|
||||
"os"
|
||||
"sync"
|
||||
)
|
||||
|
||||
var bufPool = &sync.Pool{
|
||||
New: func() interface{} {
|
||||
return new(bytes.Buffer)
|
||||
},
|
||||
}
|
||||
|
||||
func (asset *binAsset) copy(w io.Writer) error {
|
||||
rc, err := asset.Open()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
n := 4 * 1024
|
||||
if s, ok := rc.(interface {
|
||||
Stat() (os.FileInfo, error)
|
||||
}); ok {
|
||||
if fi, err := s.Stat(); err == nil {
|
||||
// Don't preallocate a huge buffer, just in case.
|
||||
if size := fi.Size(); size < 1e9 {
|
||||
n = int(size) + bytes.MinRead
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
buf := bufPool.Get().(*bytes.Buffer)
|
||||
buf.Grow(n)
|
||||
|
||||
_, err = io.CopyBuffer(w, rc, buf.Bytes()[:buf.Cap()])
|
||||
|
||||
if closeErr := rc.Close(); err == nil {
|
||||
err = closeErr
|
||||
}
|
||||
|
||||
bufPool.Put(buf)
|
||||
return err
|
||||
}
|
51
tools/vendor/github.com/tmthrgd/go-bindata/common.go
generated
vendored
Normal file
51
tools/vendor/github.com/tmthrgd/go-bindata/common.go
generated
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
// Copyright 2017 Tom Thorogood. All rights reserved.
|
||||
// Use of this source code is governed by a Modified
|
||||
// BSD License that can be found in the LICENSE file.
|
||||
|
||||
package bindata
|
||||
|
||||
import "text/template"
|
||||
|
||||
func init() {
|
||||
template.Must(baseTemplate.New("common").Parse(`// Asset loads and returns the asset for the given name.
|
||||
// It returns an error if the asset could not be found or
|
||||
// could not be loaded.
|
||||
func Asset(name string) ([]byte, error) {
|
||||
data, _, err := AssetAndInfo(name)
|
||||
return data, err
|
||||
}
|
||||
|
||||
// MustAsset is like Asset but panics when Asset would return an error.
|
||||
// It simplifies safe initialization of global variables.
|
||||
func MustAsset(name string) []byte {
|
||||
a, err := Asset(name)
|
||||
if err != nil {
|
||||
panic("asset: Asset(" + name + "): " + err.Error())
|
||||
}
|
||||
|
||||
return a
|
||||
}
|
||||
|
||||
// AssetNames returns the names of the assets.
|
||||
func AssetNames() []string {
|
||||
names := make([]string, 0, len(_bindata))
|
||||
for name := range _bindata {
|
||||
names = append(names, name)
|
||||
}
|
||||
|
||||
return names
|
||||
}
|
||||
|
||||
{{- if $.Restore}}
|
||||
|
||||
// RestoreAsset restores an asset under the given directory
|
||||
func RestoreAsset(dir, name string) error {
|
||||
return restore.Asset(dir, name, AssetAndInfo)
|
||||
}
|
||||
|
||||
// RestoreAssets restores an asset under the given directory recursively
|
||||
func RestoreAssets(dir, name string) error {
|
||||
return restore.Assets(dir, name, AssetDir, AssetAndInfo)
|
||||
}
|
||||
{{- end}}`))
|
||||
}
|
209
tools/vendor/github.com/tmthrgd/go-bindata/config.go
generated
vendored
Normal file
209
tools/vendor/github.com/tmthrgd/go-bindata/config.go
generated
vendored
Normal file
@@ -0,0 +1,209 @@
|
||||
// Copyright 2017 Tom Thorogood. All rights reserved.
|
||||
// Use of this source code is governed by a Modified
|
||||
// BSD License that can be found in the LICENSE file.
|
||||
|
||||
package bindata
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"hash"
|
||||
"os"
|
||||
|
||||
"github.com/tmthrgd/go-bindata/internal/identifier"
|
||||
)
|
||||
|
||||
// HashFormat specifies which format to use when hashing names.
|
||||
type HashFormat int
|
||||
|
||||
const (
|
||||
// NameUnchanged leaves the file name unchanged.
|
||||
NameUnchanged HashFormat = iota
|
||||
// DirHash formats names like path/to/hash/name.ext.
|
||||
DirHash
|
||||
// NameHashSuffix formats names like path/to/name-hash.ext.
|
||||
NameHashSuffix
|
||||
// HashWithExt formats names like path/to/hash.ext.
|
||||
HashWithExt
|
||||
)
|
||||
|
||||
func (hf HashFormat) String() string {
|
||||
switch hf {
|
||||
case NameUnchanged:
|
||||
return "unchanged"
|
||||
case DirHash:
|
||||
return "dir"
|
||||
case NameHashSuffix:
|
||||
return "namesuffix"
|
||||
case HashWithExt:
|
||||
return "hashext"
|
||||
default:
|
||||
return "unknown"
|
||||
}
|
||||
}
|
||||
|
||||
// HashEncoding specifies which encoding to use when hashing names.
|
||||
type HashEncoding int
|
||||
|
||||
const (
|
||||
// HexHash uses hexadecimal encoding.
|
||||
HexHash HashEncoding = iota
|
||||
// Base32Hash uses unpadded, lowercase standard base32
|
||||
// encoding (see RFC 4648).
|
||||
Base32Hash
|
||||
// Base64Hash uses an unpadded URL-safe base64 encoding
|
||||
// defined in RFC 4648.
|
||||
Base64Hash
|
||||
)
|
||||
|
||||
func (he HashEncoding) String() string {
|
||||
switch he {
|
||||
case HexHash:
|
||||
return "hex"
|
||||
case Base32Hash:
|
||||
return "base32"
|
||||
case Base64Hash:
|
||||
return "base64"
|
||||
default:
|
||||
return "unknown"
|
||||
}
|
||||
}
|
||||
|
||||
// GenerateOptions defines a set of options to use
|
||||
// when generating the Go code.
|
||||
type GenerateOptions struct {
|
||||
// Name of the package to use.
|
||||
Package string
|
||||
|
||||
// Tags specify a set of optional build tags, which should be
|
||||
// included in the generated output. The tags are appended to a
|
||||
// `// +build` line in the beginning of the output file
|
||||
// and must follow the build tags syntax specified by the go tool.
|
||||
Tags string
|
||||
|
||||
// MemCopy will alter the way the output file is generated.
|
||||
//
|
||||
// If false, it will employ a hack that allows us to read the file data directly
|
||||
// from the compiled program's `.rodata` section. This ensures that when we call
|
||||
// call our generated function, we omit unnecessary mem copies.
|
||||
//
|
||||
// The downside of this, is that it requires dependencies on the `reflect` and
|
||||
// `unsafe` packages. These may be restricted on platforms like AppEngine and
|
||||
// thus prevent you from using this mode.
|
||||
//
|
||||
// Another disadvantage is that the byte slice we create, is strictly read-only.
|
||||
// For most use-cases this is not a problem, but if you ever try to alter the
|
||||
// returned byte slice, a runtime panic is thrown. Use this mode only on target
|
||||
// platforms where memory constraints are an issue.
|
||||
//
|
||||
// The default behaviour is to use the old code generation method. This
|
||||
// prevents the two previously mentioned issues, but will employ at least one
|
||||
// extra memcopy and thus increase memory requirements.
|
||||
//
|
||||
// For instance, consider the following two examples:
|
||||
//
|
||||
// This would be the default mode, using an extra memcopy but gives a safe
|
||||
// implementation without dependencies on `reflect` and `unsafe`:
|
||||
//
|
||||
// func myfile() []byte {
|
||||
// return []byte{0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a}
|
||||
// }
|
||||
//
|
||||
// Here is the same functionality, but uses the `.rodata` hack.
|
||||
// The byte slice returned from this example can not be written to without
|
||||
// generating a runtime error.
|
||||
//
|
||||
// var _myfile = "\x89\x50\x4e\x47\x0d\x0a\x1a"
|
||||
//
|
||||
// func myfile() []byte {
|
||||
// var empty [0]byte
|
||||
// sx := (*reflect.StringHeader)(unsafe.Pointer(&_myfile))
|
||||
// b := empty[:]
|
||||
// bx := (*reflect.SliceHeader)(unsafe.Pointer(&b))
|
||||
// bx.Data = sx.Data
|
||||
// bx.Len = len(_myfile)
|
||||
// bx.Cap = bx.Len
|
||||
// return b
|
||||
// }
|
||||
MemCopy bool
|
||||
|
||||
// Compress means the assets are GZIP compressed before being turned into
|
||||
// Go code. The generated function will automatically unzip the file data
|
||||
// when called. Defaults to true.
|
||||
Compress bool
|
||||
|
||||
// Perform a debug build. This generates an asset file, which
|
||||
// loads the asset contents directly from disk at their original
|
||||
// location, instead of embedding the contents in the code.
|
||||
//
|
||||
// This is mostly useful if you anticipate that the assets are
|
||||
// going to change during your development cycle. You will always
|
||||
// want your code to access the latest version of the asset.
|
||||
// Only in release mode, will the assets actually be embedded
|
||||
// in the code. The default behaviour is Release mode.
|
||||
Debug bool
|
||||
|
||||
// Perform a dev build, which is nearly identical to the debug option. The
|
||||
// only difference is that instead of absolute file paths in generated code,
|
||||
// it expects a variable, `rootDir`, to be set in the generated code's
|
||||
// package (the author needs to do this manually), which it then prepends to
|
||||
// an asset's name to construct the file path on disk.
|
||||
//
|
||||
// This is mainly so you can push the generated code file to a shared
|
||||
// repository.
|
||||
Dev bool
|
||||
|
||||
// When true, the AssetDir API will be provided.
|
||||
AssetDir bool
|
||||
|
||||
// When true, only gzip decompress the data on first use.
|
||||
DecompressOnce bool
|
||||
|
||||
// [Deprecated]: use github.com/tmthrgd/go-bindata/restore.
|
||||
Restore bool
|
||||
|
||||
// When false, size, mode and modtime are not preserved from files
|
||||
Metadata bool
|
||||
// When nonzero, use this as mode for all files.
|
||||
Mode os.FileMode
|
||||
// When nonzero, use this as unix timestamp for all files.
|
||||
ModTime int64
|
||||
|
||||
// Hash is used to produce a hash of the file.
|
||||
Hash hash.Hash
|
||||
// Which of the given name hashing formats to use.
|
||||
HashFormat HashFormat
|
||||
// The length of the hash to use, defaults to 16 characters.
|
||||
HashLength uint
|
||||
// The encoding to use to encode the name hash.
|
||||
HashEncoding HashEncoding
|
||||
}
|
||||
|
||||
// validate ensures the config has sane values.
|
||||
// Part of which means checking if certain file/directory paths exist.
|
||||
func (opts *GenerateOptions) validate() error {
|
||||
if len(opts.Package) == 0 {
|
||||
return errors.New("go-bindata: missing package name")
|
||||
}
|
||||
|
||||
if identifier.Identifier(opts.Package) != opts.Package {
|
||||
return errors.New("go-bindata: package name is not valid identifier")
|
||||
}
|
||||
|
||||
if opts.Metadata && (opts.Mode != 0 && opts.ModTime != 0) {
|
||||
return errors.New("go-bindata: if Metadata is true, one of Mode or ModTime must be zero")
|
||||
}
|
||||
|
||||
if opts.Mode&^os.ModePerm != 0 {
|
||||
return errors.New("go-bindata: invalid mode specified")
|
||||
}
|
||||
|
||||
if opts.Hash != nil && (opts.Debug || opts.Dev) {
|
||||
return errors.New("go-bindata: Hash is not compatible with Debug and Dev")
|
||||
}
|
||||
|
||||
if opts.Restore && !opts.AssetDir {
|
||||
return errors.New("go-bindata: Restore cannot be used without AssetDir")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
68
tools/vendor/github.com/tmthrgd/go-bindata/corpus-sha256sums
generated
vendored
Normal file
68
tools/vendor/github.com/tmthrgd/go-bindata/corpus-sha256sums
generated
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
fc42e0de8a85c266577354c445ac1c1e442518a5b4c8ee9805412e43122f71fb asset-dir.go
|
||||
e75b6c1141dc6b286c9fe93d6a94ff417af042e3b619db1a7d8f58451e984e34 compress.go
|
||||
528410b942177ea42119c5f23e39085cbf9dfce8ba96d509f5345609e59ce309 copy.go
|
||||
4b6c823a2574f6c5f1cdc3437092b06297c0c6708e6e418c336a704a3bd6d3eb debug.go
|
||||
1c0b2f7a7f97f82a4d89ce82b20a851772ddc7c8865528867bf6ca1977c7ac45 decompress-once.go
|
||||
036697010d259574c5a15edb33f1e286af58a40e1ab91200b2a4b7d9fc40f187 default.go
|
||||
63cb3ba6ffc51486843abe7eb2370c07a0d05146fc34a2379b364d68a31b49ef dev.go
|
||||
b3d63994930c24602ebbe40437d07bdda9720d1cde48df43befd8a553e90504b hash-copy.go
|
||||
33f7e152f69bc9e9881d74c82e3e27a2c130d1592b96727d3467615ee700788e hash-dir.go
|
||||
3b8ff973c806b675eb75c227a0fe5d708dd2b4b8e3174b98391cbf3480877ece hash-enc-b32.go
|
||||
38395de6c76cbf57eb6fc028b3d317ba2b2a5d9a843fb970df3a6f62b09a1fce hash-enc-b64.go
|
||||
cbb867c075721ae0b7f85d00227e81f607f6310135379a5f4d98fb298909f56a hash-hashext.go
|
||||
a9af7ffafc51642ef48af1d7622ff6a88c0c0c1b831cae2509ed769b12b52097 hash-suffix.go
|
||||
362b96b80fae7b41934a33d8514d71664acb041624c981c61c172d4037502eaf hash-unchanged.go
|
||||
e0512fb269ace4db9df83c075d9f82fceb63e3551a3c25e2dc551f67dc7c72f4 metadata.go
|
||||
6cf3e7ac27ab257f89f37b9353ccb10cab8011072e9209cdf1700af82b0b1ac4 old-default.go
|
||||
bf6f8e4f11b730a5ac3b13040d2ba50785296b6f993f1e0640fdc3c3e53f4d85 package.go
|
||||
a59cbba67616477980ca99dc678a8e66270494235f84a203372841737535f824 random-#10.go
|
||||
3ef50db7180413665ea96ebb63b6656168937a106fa9dbf0120cc2c40e166b20 random-#11.go
|
||||
ac6d298a012ddf45ff33655d37b9e64c6a75ee2756038b0896b3f98a38a29c66 random-#12.go
|
||||
a65c8e35b650cd922b85804314234415adc0732d9b46a2a95be5616e725a9341 random-#13.go
|
||||
fad9e724379617bddb4131bcd93e2608f867782acae1439d9419dc356701ab0d random-#14.go
|
||||
e96ccf210c4b1b8e51942ae8674d9dd3f38f71920bc54dc3590362e6ec8b7faf random-#15.go
|
||||
d8a1df711301ba25dfb90204a953aa0722e7c821e03b90f84797dfafec418de3 random-#16.go
|
||||
9256675f720083bf23aa380a0365a35b8719591bfb2f51b7e306e74c7a34d38a random-#17.go
|
||||
f50b6362f47eeb7cfdadd4ab2f309fd2c99c76031c9e7335ff6ce06ab3c70285 random-#18.go
|
||||
cc477c7647957306931d72b521a8d6919edd41f2bccf2dd8508381bf9f5105fe random-#19.go
|
||||
5bd5a4569b63a4a3d2399c943fa5d6d813a0e1e97b36b009503549e34668fb81 random-#1.go
|
||||
8a8a0fc1a2e417cba60eb025d3ce741897e69906b9133cdc10b7ac61bbb27bf4 random-#20.go
|
||||
43d34aaad7e9a6c6192126bb941f94305bca8b61c77581662bc7ce5f2dbcbdc9 random-#21.go
|
||||
b4798deab1655ad7b5e8b5b7cd1f51b444ff4a2560107fd9787535ab1d3d7f80 random-#22.go
|
||||
6ee3706961f8d6e80ed40e8603678371524259dc30cfeb4d335a354f4ebf7f07 random-#23.go
|
||||
4d74619c90d2c9385e28ef2321964878a88395f3b6968d67c003e3cb16a822b1 random-#24.go
|
||||
34742bb4fc1edaea5a4fe679d1c0717b54445c52421e31b06fe73e8744bf0734 random-#25.go
|
||||
a61cf74fdcd8b6bbbcbf02a3c58a52be164603fc6082facf7158c132bf5824aa random-#26.go
|
||||
2d78d2006d49fcdd45d7b8f6b4318cd799f194067bf3fc635b33178161c7d63c random-#27.go
|
||||
d348b22e3fdc3c98da7a7564483b08742cef36f54f3e30500ecf69ccd0b97777 random-#28.go
|
||||
ebedf92840958164911c44045dfce0d3c7ed18973a3893bcfb6f9239e13b31b8 random-#29.go
|
||||
c5ca8a9518e5f0926d48a621d595f48d76cb2891a40c0b22f3534a3a91031a4f random-#2.go
|
||||
a0c77fa7246dd63e5f5dc4663d52cf6abf0e425a86726ebb96973f5b709f97c6 random-#30.go
|
||||
d8d8ef43d718981ead2725cd15a17ef6fc33956dbca65bc9fd5ef5cf6b8da066 random-#31.go
|
||||
254b340abe80d09fd7c6ba21bd7050b705462d7b6d640789489a3dfb3c1620de random-#32.go
|
||||
d5dc83c6b344fd3374438c59fe1d2e42e6f5c15fcc11aeb2248f6a7f6882b596 random-#33.go
|
||||
073ecfa891403d7a87d170fa6c9394ee2a2fff6d8fe621d68b3da0fdad2438e4 random-#34.go
|
||||
7a293b4be49a2813643a74d32c91cc0a1cf1010a760d5d6ae40e3a94da70d70d random-#35.go
|
||||
02fac0bed12bce3cf4ffb00376079f5b816634bc1b59a451643c1e8c0e860837 random-#36.go
|
||||
201e6fab72a37d75665107b09dee6fb84722d4265fc8400dc855f6d5a449b27d random-#37.go
|
||||
38d1db1022acb1e92725e6bb8caf8bcfbd5dea0ae85f8bd903c6c16993d51ee5 random-#38.go
|
||||
a7ba47ad58d95821fede9cf11339b35e19c4173eb35131a459ed431dbb02a573 random-#39.go
|
||||
42ad847d45c941ca674e660a581867c07f1f568242cac008589cdee8500474e2 random-#3.go
|
||||
c38ad926d43afa044e784fc41a1f1576a1207713c390c1cc9d5f5c800ad7c056 random-#40.go
|
||||
e300d3ccfbc656eefebd30e6b341a081163aea6b8e1e2d2bbad8ee9b5b82a1b5 random-#41.go
|
||||
fc7d235f1f12d9d2d96be00810e66572a63adb86ff7cba17e77bc45018ade66a random-#42.go
|
||||
56415a962fdd0a3453526620ad8dff8b90b5731f3b5f8247c0d33e35ae343002 random-#43.go
|
||||
4ca790becea62b89cb687f81819f09f27274a2f64f6ca0ab919b07577d3ea12f random-#44.go
|
||||
154ba30b7bd61dac5234e5616e2b5097722001234119442bcde4e4aa5db0a43a random-#45.go
|
||||
86bbb3ad9cbba89cb1262677d490dd3a87ca091892010381fffdd2af8ad74761 random-#46.go
|
||||
0d6b42a9702911ef1593047197dd19d0c6402a9b4542e53697281109b8eca566 random-#47.go
|
||||
6384db969ed03ae0704657fbf3ad5b25a169f2166ee8cd643daa9d887af59aae random-#48.go
|
||||
bf3ba0bc573208fdcc6a48067d4fbfb965da54f6b641752e192197a2db480120 random-#49.go
|
||||
af77fcf2ac300945c9c726d0f1de13366522f4f6cb44190d036a86c140eb54d1 random-#4.go
|
||||
f672c3e1c8b3449695167bfad4b68dd7aff36b4d0148a1d82e429c3eb24be99c random-#50.go
|
||||
7a9900d444ae8ec5e241a58dd2cca600d1dc2d1101d8f23e3dc65fcd2c2e560f random-#5.go
|
||||
dd19e896cdb36b1e697f5e2e9e8ebf313c3ee2bd92412097f9ec1742635f11cf random-#6.go
|
||||
f458f51ae48736aaa14fd0720322114c303ebab93d2dc6dddc33a1fb759407f1 random-#7.go
|
||||
eb785847c9dbdd927b98e71376d00aca87e887a380b67ce8448c39b0caff5d98 random-#8.go
|
||||
a27d2578f5aefa2086c3a296f1b1af989e126cce226a4a04172a37a7048f39eb random-#9.go
|
||||
b1278bab5b1741bef1f32893397b8b1c61fa59182d95ca0c236c8995e24d9aa7 tags.go
|
7
tools/vendor/github.com/tmthrgd/go-bindata/corpus_test_travis.sh
generated
vendored
Executable file
7
tools/vendor/github.com/tmthrgd/go-bindata/corpus_test_travis.sh
generated
vendored
Executable file
@@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
set -ev
|
||||
|
||||
if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then
|
||||
go test -v -race -run TestCorpus -randtests 50 -corpus .travis-corpus -gencorpus .
|
||||
cd .travis-corpus && sha256sum -c --quiet --strict ../corpus-sha256sums
|
||||
fi
|
84
tools/vendor/github.com/tmthrgd/go-bindata/debug.go
generated
vendored
Normal file
84
tools/vendor/github.com/tmthrgd/go-bindata/debug.go
generated
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
// Copyright 2017 Tom Thorogood. All rights reserved.
|
||||
// Use of this source code is governed by a Modified
|
||||
// BSD License that can be found in the LICENSE file.
|
||||
|
||||
package bindata
|
||||
|
||||
import "text/template"
|
||||
|
||||
func init() {
|
||||
template.Must(template.Must(template.Must(baseTemplate.New("debug").Funcs(template.FuncMap{
|
||||
"format": formatTemplate,
|
||||
}).Parse(`import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
{{- if $.AssetDir}}
|
||||
"strings"
|
||||
{{- end}}
|
||||
{{- if $.Restore}}
|
||||
|
||||
"github.com/tmthrgd/go-bindata/restore"
|
||||
{{- end}}
|
||||
)
|
||||
|
||||
// AssetAndInfo loads and returns the asset and asset info for the
|
||||
// given name. It returns an error if the asset could not be found
|
||||
// or could not be loaded.
|
||||
func AssetAndInfo(name string) ([]byte, os.FileInfo, error) {
|
||||
path, ok := _bindata[filepath.ToSlash(name)]
|
||||
if !ok {
|
||||
return nil, nil, &os.PathError{Op: "open", Path: name, Err: os.ErrNotExist}
|
||||
}
|
||||
|
||||
{{- if $.Dev}}
|
||||
|
||||
path = filepath.Join(rootDir, path)
|
||||
{{- end}}
|
||||
|
||||
data, err := ioutil.ReadFile(path)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
fi, err := os.Stat(path)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
return data, fi, nil
|
||||
}
|
||||
|
||||
// AssetInfo loads and returns the asset info for the given name.
|
||||
// It returns an error if the asset could not be found or
|
||||
// could not be loaded.
|
||||
func AssetInfo(name string) (os.FileInfo, error) {
|
||||
path, ok := _bindata[filepath.ToSlash(name)]
|
||||
if !ok {
|
||||
return nil, &os.PathError{Op: "open", Path: name, Err: os.ErrNotExist}
|
||||
}
|
||||
|
||||
{{- if $.Dev}}
|
||||
|
||||
path = filepath.Join(rootDir, path)
|
||||
{{- end}}
|
||||
return os.Stat(path)
|
||||
}
|
||||
|
||||
// _bindata is a table, mapping each file to its path.
|
||||
{{if $.Dev -}}
|
||||
{{format "bindata-dev" $}}
|
||||
{{- else -}}
|
||||
{{format "bindata-debug" $}}
|
||||
{{- end}}`)).New("bindata-debug").Parse(`
|
||||
var _bindata = map[string]string{
|
||||
{{range .Assets -}}
|
||||
{{printf "%q" .Name}}: {{printf "%q" .AbsolutePath}},
|
||||
{{end -}}
|
||||
}`)).New("bindata-dev").Parse(`
|
||||
var _bindata = map[string]string{
|
||||
{{range .Assets -}}
|
||||
{{printf "%q" .Name}}: {{printf "%q" .Name}},
|
||||
{{end -}}
|
||||
}`))
|
||||
}
|
128
tools/vendor/github.com/tmthrgd/go-bindata/doc.go
generated
vendored
Normal file
128
tools/vendor/github.com/tmthrgd/go-bindata/doc.go
generated
vendored
Normal file
@@ -0,0 +1,128 @@
|
||||
// Copyright 2017 Tom Thorogood. All rights reserved.
|
||||
// Use of this source code is governed by a Modified
|
||||
// BSD License that can be found in the LICENSE file.
|
||||
|
||||
/*
|
||||
Package bindata converts any file into manageable Go source code. Useful for
|
||||
embedding binary data into a go program. The file data is optionally gzip
|
||||
compressed before being converted to a raw byte slice.
|
||||
|
||||
The following paragraphs cover some of the customization options
|
||||
which can be specified in the Config struct, which must be passed into
|
||||
the Translate() call.
|
||||
|
||||
|
||||
Debug vs Release builds
|
||||
|
||||
When used with the `Debug` option, the generated code does not actually include
|
||||
the asset data. Instead, it generates function stubs which load the data from
|
||||
the original file on disk. The asset API remains identical between debug and
|
||||
release builds, so your code will not have to change.
|
||||
|
||||
This is useful during development when you expect the assets to change often.
|
||||
The host application using these assets uses the same API in both cases and
|
||||
will not have to care where the actual data comes from.
|
||||
|
||||
An example is a Go webserver with some embedded, static web content like
|
||||
HTML, JS and CSS files. While developing it, you do not want to rebuild the
|
||||
whole server and restart it every time you make a change to a bit of
|
||||
javascript. You just want to build and launch the server once. Then just press
|
||||
refresh in the browser to see those changes. Embedding the assets with the
|
||||
`debug` flag allows you to do just that. When you are finished developing and
|
||||
ready for deployment, just re-invoke `go-bindata` without the `-debug` flag.
|
||||
It will now embed the latest version of the assets.
|
||||
|
||||
|
||||
Lower memory footprint
|
||||
|
||||
The `MemCopy` option will alter the way the output file is generated.
|
||||
If false, it will employ a hack that allows us to read the file data directly
|
||||
from the compiled program's `.rodata` section. This ensures that when we call
|
||||
call our generated function, we omit unnecessary memcopies.
|
||||
|
||||
The downside of this, is that it requires dependencies on the `reflect` and
|
||||
`unsafe` packages. These may be restricted on platforms like AppEngine and
|
||||
thus prevent you from using this mode.
|
||||
|
||||
Another disadvantage is that the byte slice we create, is strictly read-only.
|
||||
For most use-cases this is not a problem, but if you ever try to alter the
|
||||
returned byte slice, a runtime panic is thrown. Use this mode only on target
|
||||
platforms where memory constraints are an issue.
|
||||
|
||||
The default behaviour is to use the old code generation method. This
|
||||
prevents the two previously mentioned issues, but will employ at least one
|
||||
extra memcopy and thus increase memory requirements.
|
||||
|
||||
For instance, consider the following two examples:
|
||||
|
||||
This would be the default mode, using an extra memcopy but gives a safe
|
||||
implementation without dependencies on `reflect` and `unsafe`:
|
||||
|
||||
func myfile() []byte {
|
||||
return []byte{0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a}
|
||||
}
|
||||
|
||||
Here is the same functionality, but uses the `.rodata` hack.
|
||||
The byte slice returned from this example can not be written to without
|
||||
generating a runtime error.
|
||||
|
||||
var _myfile = "\x89\x50\x4e\x47\x0d\x0a\x1a"
|
||||
|
||||
func myfile() []byte {
|
||||
var empty [0]byte
|
||||
sx := (*reflect.StringHeader)(unsafe.Pointer(&_myfile))
|
||||
b := empty[:]
|
||||
bx := (*reflect.SliceHeader)(unsafe.Pointer(&b))
|
||||
bx.Data = sx.Data
|
||||
bx.Len = len(_myfile)
|
||||
bx.Cap = bx.Len
|
||||
return b
|
||||
}
|
||||
|
||||
|
||||
Optional compression
|
||||
|
||||
The Compress option indicates that the supplied assets are GZIP compressed before
|
||||
being turned into Go code. The data should still be accessed through a function
|
||||
call, so nothing changes in the API.
|
||||
|
||||
This feature is useful if you do not care for compression, or the supplied
|
||||
resource is already compressed. Doing it again would not add any value and may
|
||||
even increase the size of the data.
|
||||
|
||||
The default behaviour of the program is to use compression.
|
||||
|
||||
|
||||
Path prefix stripping
|
||||
|
||||
The keys used in the `_bindata` map are the same as the input file name
|
||||
passed to `go-bindata`. This includes the path. In most cases, this is not
|
||||
desirable, as it puts potentially sensitive information in your code base.
|
||||
For this purpose, the tool supplies another command line flag `-prefix`.
|
||||
This accepts a portion of a path name, which should be stripped off from
|
||||
the map keys and function names.
|
||||
|
||||
For example, running without the `-prefix` flag, we get:
|
||||
|
||||
$ go-bindata /path/to/templates/
|
||||
|
||||
_bindata["/path/to/templates/foo.html"] = path_to_templates_foo_html
|
||||
|
||||
Running with the `-prefix` flag, we get:
|
||||
|
||||
$ go-bindata -prefix "/path/to/" /path/to/templates/
|
||||
|
||||
_bindata["templates/foo.html"] = templates_foo_html
|
||||
|
||||
|
||||
Build tags
|
||||
|
||||
With the optional Tags field, you can specify any go build tags that
|
||||
must be fulfilled for the output file to be included in a build. This
|
||||
is useful when including binary data in multiple formats, where the desired
|
||||
format is specified at build time with the appropriate tags.
|
||||
|
||||
The tags are appended to a `// +build` line in the beginning of the output file
|
||||
and must follow the build tags syntax specified by the go tool.
|
||||
*/
|
||||
package bindata
|
130
tools/vendor/github.com/tmthrgd/go-bindata/files.go
generated
vendored
Normal file
130
tools/vendor/github.com/tmthrgd/go-bindata/files.go
generated
vendored
Normal file
@@ -0,0 +1,130 @@
|
||||
// Copyright 2017 Tom Thorogood. All rights reserved.
|
||||
// Use of this source code is governed by a Modified
|
||||
// BSD License that can be found in the LICENSE file.
|
||||
|
||||
package bindata
|
||||
|
||||
import (
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// File represents a single asset file.
|
||||
type File interface {
|
||||
// Name returns the name by which asset is referenced.
|
||||
Name() string
|
||||
// Path returns the relative path to the file.
|
||||
Path() string
|
||||
// AbsolutePath returns the absolute path to the file.
|
||||
AbsolutePath() string
|
||||
|
||||
// Open returns an io.ReadCloser for reading the file.
|
||||
Open() (io.ReadCloser, error)
|
||||
// Stat returns an os.FileInfo interface representing the file.
|
||||
Stat() (os.FileInfo, error)
|
||||
}
|
||||
|
||||
// Files represents a collection of asset files.
|
||||
type Files []File
|
||||
|
||||
type osFile struct {
|
||||
name string
|
||||
path string
|
||||
}
|
||||
|
||||
func (f *osFile) Name() string {
|
||||
return f.name
|
||||
}
|
||||
|
||||
func (f *osFile) Path() string {
|
||||
return f.path
|
||||
}
|
||||
|
||||
func (f *osFile) AbsolutePath() string {
|
||||
path, err := filepath.Abs(f.path)
|
||||
if err != nil {
|
||||
return f.path
|
||||
}
|
||||
|
||||
return path
|
||||
}
|
||||
|
||||
func (f *osFile) Open() (io.ReadCloser, error) {
|
||||
return os.Open(f.path)
|
||||
}
|
||||
|
||||
func (f *osFile) Stat() (os.FileInfo, error) {
|
||||
return os.Stat(f.path)
|
||||
}
|
||||
|
||||
// FindFilesOptions defines a set of options to use
|
||||
// when searching for files.
|
||||
type FindFilesOptions struct {
|
||||
// Prefix defines a path prefix which should be stripped from all
|
||||
// file names when generating the keys in the table of contents.
|
||||
// For example, running without the `-prefix` flag, we get:
|
||||
//
|
||||
// $ go-bindata /path/to/templates
|
||||
// go_bindata["/path/to/templates/foo.html"] = _path_to_templates_foo_html
|
||||
//
|
||||
// Running with the `-prefix` flag, we get:
|
||||
//
|
||||
// $ go-bindata -prefix "/path/to/" /path/to/templates/foo.html
|
||||
// go_bindata["templates/foo.html"] = templates_foo_html
|
||||
Prefix string
|
||||
|
||||
// Recursive defines whether subdirectories of Path
|
||||
// should be recursively included in the conversion.
|
||||
Recursive bool
|
||||
|
||||
// Ignores any filenames matching the regex pattern specified, e.g.
|
||||
// path/to/file.ext will ignore only that file, or \\.gitignore
|
||||
// will match any .gitignore file.
|
||||
//
|
||||
// This parameter can be provided multiple times.
|
||||
Ignore []*regexp.Regexp
|
||||
}
|
||||
|
||||
// FindFiles adds all files inside a directory to the
|
||||
// generated output.
|
||||
func FindFiles(path string, opts *FindFilesOptions) (files Files, err error) {
|
||||
if opts == nil {
|
||||
opts = new(FindFilesOptions)
|
||||
}
|
||||
|
||||
if err = filepath.Walk(path, func(assetPath string, info os.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if info.IsDir() {
|
||||
if !opts.Recursive && assetPath != path {
|
||||
return filepath.SkipDir
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
for _, re := range opts.Ignore {
|
||||
if re.MatchString(assetPath) {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
name := strings.TrimPrefix(filepath.ToSlash(
|
||||
strings.TrimPrefix(assetPath, opts.Prefix)), "/")
|
||||
if name == "" {
|
||||
panic("should be impossible")
|
||||
}
|
||||
|
||||
files = append(files, &osFile{name, assetPath})
|
||||
return nil
|
||||
}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return
|
||||
}
|
47
tools/vendor/github.com/tmthrgd/go-bindata/format.go
generated
vendored
Normal file
47
tools/vendor/github.com/tmthrgd/go-bindata/format.go
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
// Copyright 2017 Tom Thorogood. All rights reserved.
|
||||
// Use of this source code is governed by a Modified
|
||||
// BSD License that can be found in the LICENSE file.
|
||||
|
||||
package bindata
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"go/parser"
|
||||
"go/printer"
|
||||
"go/token"
|
||||
)
|
||||
|
||||
var printerConfig = printer.Config{
|
||||
Mode: printer.UseSpaces | printer.TabIndent,
|
||||
Tabwidth: 8,
|
||||
}
|
||||
|
||||
func formatTemplate(name string, data interface{}) (string, error) {
|
||||
buf := bufPool.Get().(*bytes.Buffer)
|
||||
defer func() {
|
||||
buf.Reset()
|
||||
bufPool.Put(buf)
|
||||
}()
|
||||
|
||||
buf.WriteString("package main;")
|
||||
|
||||
if err := baseTemplate.ExecuteTemplate(buf, name, data); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
fset := token.NewFileSet()
|
||||
|
||||
f, err := parser.ParseFile(fset, "", buf, parser.ParseComments)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
buf.Reset()
|
||||
|
||||
if err = printerConfig.Fprint(buf, fset, f); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
out := string(bytes.TrimSpace(buf.Bytes()[len("package main\n"):]))
|
||||
return out, nil
|
||||
}
|
76
tools/vendor/github.com/tmthrgd/go-bindata/generate.go
generated
vendored
Normal file
76
tools/vendor/github.com/tmthrgd/go-bindata/generate.go
generated
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
// Copyright 2017 Tom Thorogood. All rights reserved.
|
||||
// Use of this source code is governed by a Modified
|
||||
// BSD License that can be found in the LICENSE file.
|
||||
|
||||
package bindata
|
||||
|
||||
import (
|
||||
"io"
|
||||
"text/template"
|
||||
)
|
||||
|
||||
// binAsset holds information about a single asset to be processed.
|
||||
type binAsset struct {
|
||||
File
|
||||
|
||||
opts *GenerateOptions
|
||||
Hash []byte // Generated hash of file.
|
||||
mangledName string
|
||||
}
|
||||
|
||||
// Generate writes the generated Go code to w.
|
||||
func (f Files) Generate(w io.Writer, opts *GenerateOptions) error {
|
||||
if opts == nil {
|
||||
opts = &GenerateOptions{Package: "main"}
|
||||
}
|
||||
|
||||
err := opts.validate()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
assets := make([]binAsset, 0, len(f))
|
||||
for i, file := range f {
|
||||
asset := binAsset{
|
||||
File: file,
|
||||
|
||||
opts: opts,
|
||||
}
|
||||
|
||||
if opts.Hash != nil {
|
||||
if i != 0 {
|
||||
opts.Hash.Reset()
|
||||
}
|
||||
|
||||
if err = asset.copy(opts.Hash); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
asset.Hash = opts.Hash.Sum(nil)
|
||||
}
|
||||
|
||||
assets = append(assets, asset)
|
||||
}
|
||||
|
||||
return baseTemplate.Execute(w, struct {
|
||||
*GenerateOptions
|
||||
Assets []binAsset
|
||||
}{opts, assets})
|
||||
}
|
||||
|
||||
var baseTemplate = template.Must(template.New("base").Parse(`
|
||||
{{- template "header" .}}
|
||||
|
||||
{{if or $.Debug $.Dev -}}
|
||||
{{- template "debug" . -}}
|
||||
{{- else -}}
|
||||
{{- template "release" . -}}
|
||||
{{- end}}
|
||||
|
||||
{{template "common" . -}}
|
||||
|
||||
{{- if $.AssetDir}}
|
||||
|
||||
{{template "tree" . -}}
|
||||
{{- end}}
|
||||
`))
|
44
tools/vendor/github.com/tmthrgd/go-bindata/go-bindata/appendRegexValue.go
generated
vendored
Normal file
44
tools/vendor/github.com/tmthrgd/go-bindata/go-bindata/appendRegexValue.go
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
// Copyright 2017 Tom Thorogood. All rights reserved.
|
||||
// Use of this source code is governed by a Modified
|
||||
// BSD License that can be found in the LICENSE file.
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"regexp"
|
||||
)
|
||||
|
||||
type appendRegexValue []*regexp.Regexp
|
||||
|
||||
func (ar *appendRegexValue) String() string {
|
||||
if ar == nil {
|
||||
return ""
|
||||
}
|
||||
|
||||
var buf bytes.Buffer
|
||||
|
||||
for i, r := range *ar {
|
||||
if i != 0 {
|
||||
buf.WriteString(", ")
|
||||
}
|
||||
|
||||
buf.WriteString(r.String())
|
||||
}
|
||||
|
||||
return buf.String()
|
||||
}
|
||||
|
||||
func (ar *appendRegexValue) Set(value string) error {
|
||||
r, err := regexp.Compile(value)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if *ar == nil {
|
||||
*ar = make([]*regexp.Regexp, 0, 1)
|
||||
}
|
||||
|
||||
*ar = append(*ar, r)
|
||||
return nil
|
||||
}
|
178
tools/vendor/github.com/tmthrgd/go-bindata/go-bindata/main.go
generated
vendored
Normal file
178
tools/vendor/github.com/tmthrgd/go-bindata/go-bindata/main.go
generated
vendored
Normal file
@@ -0,0 +1,178 @@
|
||||
// Copyright 2017 Tom Thorogood. All rights reserved.
|
||||
// Use of this source code is governed by a Modified
|
||||
// BSD License that can be found in the LICENSE file.
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/tmthrgd/go-bindata"
|
||||
"github.com/tmthrgd/go-bindata/internal/identifier"
|
||||
)
|
||||
|
||||
func must(err error) {
|
||||
if err == nil {
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Fprintf(os.Stderr, "go-bindata: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
func main() {
|
||||
genOpts, findOpts, output := parseArgs()
|
||||
|
||||
var all bindata.Files
|
||||
|
||||
for i := 0; i < flag.NArg(); i++ {
|
||||
var path string
|
||||
path, findOpts.Recursive = parseInput(flag.Arg(i))
|
||||
|
||||
files, err := bindata.FindFiles(path, findOpts)
|
||||
must(err)
|
||||
|
||||
all = append(all, files...)
|
||||
}
|
||||
|
||||
f, err := os.OpenFile(output, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0666)
|
||||
must(err)
|
||||
|
||||
defer f.Close()
|
||||
|
||||
must(all.Generate(f, genOpts))
|
||||
}
|
||||
|
||||
// parseArgs create s a new, filled configuration instance
|
||||
// by reading and parsing command line options.
|
||||
//
|
||||
// This function exits the program with an error, if
|
||||
// any of the command line options are incorrect.
|
||||
func parseArgs() (genOpts *bindata.GenerateOptions, findOpts *bindata.FindFilesOptions, output string) {
|
||||
flag.Usage = func() {
|
||||
fmt.Printf("Usage: %s [options] <input directories>\n\n", os.Args[0])
|
||||
flag.PrintDefaults()
|
||||
}
|
||||
|
||||
var version bool
|
||||
flag.BoolVar(&version, "version", false, "Displays version information.")
|
||||
|
||||
flag.StringVar(&output, "o", "./bindata.go", "Optional name of the output file to be generated.")
|
||||
|
||||
genOpts = &bindata.GenerateOptions{
|
||||
Package: "main",
|
||||
MemCopy: true,
|
||||
Compress: true,
|
||||
Metadata: true,
|
||||
Restore: true,
|
||||
AssetDir: true,
|
||||
DecompressOnce: true,
|
||||
}
|
||||
findOpts = new(bindata.FindFilesOptions)
|
||||
|
||||
var noMemCopy, noCompress, noMetadata bool
|
||||
var mode uint
|
||||
flag.BoolVar(&genOpts.Debug, "debug", genOpts.Debug, "Do not embed the assets, but provide the embedding API. Contents will still be loaded from disk.")
|
||||
flag.BoolVar(&genOpts.Dev, "dev", genOpts.Dev, "Similar to debug, but does not emit absolute paths. Expects a rootDir variable to already exist in the generated code's package.")
|
||||
flag.StringVar(&genOpts.Tags, "tags", genOpts.Tags, "Optional set of build tags to include.")
|
||||
flag.StringVar(&findOpts.Prefix, "prefix", "", "Optional path prefix to strip off asset names.")
|
||||
flag.StringVar(&genOpts.Package, "pkg", genOpts.Package, "Package name to use in the generated code.")
|
||||
flag.BoolVar(&noMemCopy, "nomemcopy", !genOpts.MemCopy, "Use a .rodata hack to get rid of unnecessary memcopies. Refer to the documentation to see what implications this carries.")
|
||||
flag.BoolVar(&noCompress, "nocompress", !genOpts.Compress, "Assets will *not* be GZIP compressed when this flag is specified.")
|
||||
flag.BoolVar(&noMetadata, "nometadata", !genOpts.Metadata, "Assets will not preserve size, mode, and modtime info.")
|
||||
flag.UintVar(&mode, "mode", uint(genOpts.Mode), "Optional file mode override for all files.")
|
||||
flag.Int64Var(&genOpts.ModTime, "modtime", genOpts.ModTime, "Optional modification unix timestamp override for all files.")
|
||||
flag.Var((*appendRegexValue)(&findOpts.Ignore), "ignore", "Regex pattern to ignore")
|
||||
|
||||
flag.Parse()
|
||||
|
||||
if version {
|
||||
fmt.Fprintf(os.Stderr, "go-bindata (Go runtime %s).\n", runtime.Version())
|
||||
io.WriteString(os.Stderr, "Copyright (c) 2010-2013, Jim Teeuwen.\n")
|
||||
io.WriteString(os.Stderr, "Copyright (c) 2017, Tom Thorogood.\n")
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
// Make sure we have input paths.
|
||||
if flag.NArg() == 0 {
|
||||
io.WriteString(os.Stderr, "Missing <input dir>\n\n")
|
||||
flag.Usage()
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if output == "" {
|
||||
var err error
|
||||
output, err = filepath.Abs("bindata.go")
|
||||
must(err)
|
||||
}
|
||||
|
||||
genOpts.MemCopy = !noMemCopy
|
||||
genOpts.Compress = !noCompress
|
||||
genOpts.Metadata = !noMetadata && (genOpts.Mode == 0 || genOpts.ModTime == 0)
|
||||
|
||||
genOpts.Mode = os.FileMode(mode)
|
||||
|
||||
var pkgSet, outputSet bool
|
||||
flag.Visit(func(f *flag.Flag) {
|
||||
switch f.Name {
|
||||
case "pkg":
|
||||
pkgSet = true
|
||||
case "o":
|
||||
outputSet = true
|
||||
}
|
||||
})
|
||||
|
||||
// Change pkg to containing directory of output. If output flag is set and package flag is not.
|
||||
if outputSet && !pkgSet {
|
||||
pkg := identifier.Identifier(filepath.Base(filepath.Dir(output)))
|
||||
if pkg != "" {
|
||||
genOpts.Package = pkg
|
||||
}
|
||||
}
|
||||
|
||||
if !genOpts.MemCopy && genOpts.Compress {
|
||||
io.WriteString(os.Stderr, "The use of -nomemcopy without -nocompress is deprecated.\n")
|
||||
}
|
||||
|
||||
must(validateOutput(output))
|
||||
return
|
||||
}
|
||||
|
||||
func validateOutput(output string) error {
|
||||
stat, err := os.Lstat(output)
|
||||
if err == nil {
|
||||
if stat.IsDir() {
|
||||
return errors.New("output path is a directory")
|
||||
}
|
||||
|
||||
return nil
|
||||
} else if !os.IsNotExist(err) {
|
||||
return err
|
||||
}
|
||||
|
||||
// File does not exist. This is fine, just make
|
||||
// sure the directory it is to be in exists.
|
||||
if dir, _ := filepath.Split(output); dir != "" {
|
||||
return os.MkdirAll(dir, 0744)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// parseInput determines whether the given path has a recursive indicator and
|
||||
// returns a new path with the recursive indicator chopped off if it does.
|
||||
//
|
||||
// ex:
|
||||
// /path/to/foo/... -> (/path/to/foo, true)
|
||||
// /path/to/bar -> (/path/to/bar, false)
|
||||
func parseInput(input string) (path string, recursive bool) {
|
||||
return filepath.Clean(strings.TrimSuffix(input, "/...")),
|
||||
strings.HasSuffix(input, "/...")
|
||||
}
|
73
tools/vendor/github.com/tmthrgd/go-bindata/header.go
generated
vendored
Normal file
73
tools/vendor/github.com/tmthrgd/go-bindata/header.go
generated
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
// Copyright 2017 Tom Thorogood. All rights reserved.
|
||||
// Use of this source code is governed by a Modified
|
||||
// BSD License that can be found in the LICENSE file.
|
||||
|
||||
package bindata
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"text/template"
|
||||
"unicode"
|
||||
)
|
||||
|
||||
func init() {
|
||||
template.Must(baseTemplate.New("header").Funcs(template.FuncMap{
|
||||
"trimright": func(s string) string {
|
||||
return strings.TrimRightFunc(s, unicode.IsSpace)
|
||||
},
|
||||
"toslash": filepath.ToSlash,
|
||||
}).Parse(`{{- /* This makes e.g. Github ignore diffs in generated files. */ -}}
|
||||
// Code generated by go-bindata. DO NOT EDIT.
|
||||
{{if $.Dev -}}
|
||||
// debug: dev
|
||||
{{else if $.Debug -}}
|
||||
// debug: true
|
||||
{{end -}}
|
||||
{{- if $.MemCopy -}}
|
||||
// memcopy: true
|
||||
{{end -}}
|
||||
{{- if $.Compress -}}
|
||||
// compress: true
|
||||
{{end -}}
|
||||
{{- if and $.Compress $.DecompressOnce -}}
|
||||
// decompress: once
|
||||
{{end -}}
|
||||
{{- if $.Metadata -}}
|
||||
// metadata: true
|
||||
{{end -}}
|
||||
{{- if $.Mode -}}
|
||||
// mode: {{printf "%04o" $.Mode}}
|
||||
{{end -}}
|
||||
{{- if $.ModTime -}}
|
||||
// modtime: {{$.ModTime}}
|
||||
{{end -}}
|
||||
{{- if $.AssetDir -}}
|
||||
// asset-dir: true
|
||||
{{end -}}
|
||||
{{- if $.Restore -}}
|
||||
// restore: true
|
||||
{{end -}}
|
||||
{{- if $.Hash -}}
|
||||
{{- if $.HashFormat -}}
|
||||
// hash-format: {{$.HashFormat}}
|
||||
{{else -}}
|
||||
// hash-format: unchanged
|
||||
{{end -}}
|
||||
{{- if and $.HashFormat $.HashLength (ne $.HashLength 16) -}}
|
||||
// hash-length: {{$.HashLength}}
|
||||
{{end -}}
|
||||
{{- if and $.HashFormat $.HashEncoding -}}
|
||||
// hash-encoding: {{$.HashEncoding}}
|
||||
{{end -}}
|
||||
{{- end -}}
|
||||
// sources:
|
||||
{{range .Assets -}}
|
||||
// {{toslash (trimright .Path)}}
|
||||
{{end}}
|
||||
{{if $.Tags -}} // +build {{$.Tags}}
|
||||
|
||||
{{end -}}
|
||||
|
||||
package {{$.Package}}`))
|
||||
}
|
31
tools/vendor/github.com/tmthrgd/go-bindata/internal/identifier/identifier.go
generated
vendored
Normal file
31
tools/vendor/github.com/tmthrgd/go-bindata/internal/identifier/identifier.go
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
// Copyright 2017 Tom Thorogood. All rights reserved.
|
||||
// Use of this source code is governed by a Modified
|
||||
// BSD License that can be found in the LICENSE file.
|
||||
|
||||
package identifier
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"unicode"
|
||||
"unicode/utf8"
|
||||
)
|
||||
|
||||
// Identifier removes all characters from a string that are not valid in
|
||||
// an identifier according to the Go Programming Language Specification.
|
||||
//
|
||||
// The logic in the switch statement was taken from go/source package:
|
||||
// https://github.com/golang/go/blob/a1a688fa0012f7ce3a37e9ac0070461fe8e3f28e/src/go/scanner/scanner.go#L257-#L271
|
||||
func Identifier(val string) string {
|
||||
return strings.TrimLeftFunc(strings.Map(func(ch rune) rune {
|
||||
switch {
|
||||
case 'a' <= ch && ch <= 'z' || 'A' <= ch && ch <= 'Z' || ch == '_' ||
|
||||
ch >= utf8.RuneSelf && unicode.IsLetter(ch):
|
||||
return ch
|
||||
case '0' <= ch && ch <= '9' ||
|
||||
ch >= utf8.RuneSelf && unicode.IsDigit(ch):
|
||||
return ch
|
||||
default:
|
||||
return -1
|
||||
}
|
||||
}, val), unicode.IsDigit)
|
||||
}
|
61
tools/vendor/github.com/tmthrgd/go-bindata/name.go
generated
vendored
Normal file
61
tools/vendor/github.com/tmthrgd/go-bindata/name.go
generated
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
// Copyright 2017 Tom Thorogood. All rights reserved.
|
||||
// Use of this source code is governed by a Modified
|
||||
// BSD License that can be found in the LICENSE file.
|
||||
|
||||
package bindata
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"encoding/hex"
|
||||
"path"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Name applies name hashing if required. It returns the original
|
||||
// name for NoHash and NameUnchanged and returns the mangledName
|
||||
// otherwise.
|
||||
func (asset *binAsset) Name() string {
|
||||
if asset.Hash == nil || asset.opts.HashFormat == NameUnchanged {
|
||||
return asset.File.Name()
|
||||
} else if asset.mangledName != "" {
|
||||
return asset.mangledName
|
||||
}
|
||||
|
||||
var enc string
|
||||
switch asset.opts.HashEncoding {
|
||||
case HexHash:
|
||||
enc = hex.EncodeToString(asset.Hash)
|
||||
case Base32Hash:
|
||||
enc = base32Enc.EncodeToString(asset.Hash)
|
||||
case Base64Hash:
|
||||
enc = base64.RawURLEncoding.EncodeToString(asset.Hash)
|
||||
default:
|
||||
panic("unreachable")
|
||||
}
|
||||
|
||||
l := asset.opts.HashLength
|
||||
if l == 0 {
|
||||
l = 16
|
||||
}
|
||||
|
||||
if l < uint(len(enc)) {
|
||||
enc = enc[:l]
|
||||
}
|
||||
|
||||
dir, file := path.Split(asset.File.Name())
|
||||
ext := path.Ext(file)
|
||||
|
||||
switch asset.opts.HashFormat {
|
||||
case DirHash:
|
||||
asset.mangledName = path.Join(dir, enc, file)
|
||||
case NameHashSuffix:
|
||||
file = strings.TrimSuffix(file, ext)
|
||||
asset.mangledName = path.Join(dir, file+"-"+enc+ext)
|
||||
case HashWithExt:
|
||||
asset.mangledName = path.Join(dir, enc+ext)
|
||||
default:
|
||||
panic("unreachable")
|
||||
}
|
||||
|
||||
return asset.mangledName
|
||||
}
|
328
tools/vendor/github.com/tmthrgd/go-bindata/release.go
generated
vendored
Normal file
328
tools/vendor/github.com/tmthrgd/go-bindata/release.go
generated
vendored
Normal file
@@ -0,0 +1,328 @@
|
||||
// Copyright 2017 Tom Thorogood. All rights reserved.
|
||||
// Use of this source code is governed by a Modified
|
||||
// BSD License that can be found in the LICENSE file.
|
||||
|
||||
package bindata
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"compress/flate"
|
||||
"io"
|
||||
"path"
|
||||
"strings"
|
||||
"sync"
|
||||
"text/template"
|
||||
)
|
||||
|
||||
var flatePool sync.Pool
|
||||
|
||||
func writeWrappedString(write func(io.Writer) error, indent string, wrapAt int) (string, error) {
|
||||
buf := bufPool.Get().(*bytes.Buffer)
|
||||
defer func() {
|
||||
buf.Reset()
|
||||
bufPool.Put(buf)
|
||||
}()
|
||||
|
||||
buf.WriteString("(\"\" +\n")
|
||||
buf.WriteString(indent)
|
||||
buf.WriteByte('"')
|
||||
|
||||
if err := write(&stringWriter{
|
||||
Writer: buf,
|
||||
Indent: indent,
|
||||
WrapAt: wrapAt,
|
||||
}); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
buf.WriteString("\")")
|
||||
|
||||
s := buf.String()
|
||||
|
||||
if strings.IndexByte(s[1:], '(') == -1 {
|
||||
s = s[1 : len(s)-1]
|
||||
}
|
||||
|
||||
return s, nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
template.Must(template.Must(baseTemplate.New("release").Funcs(template.FuncMap{
|
||||
"base": path.Base,
|
||||
"wrap": func(data []byte, indent string, wrapAt int) (string, error) {
|
||||
return writeWrappedString(func(w io.Writer) error {
|
||||
_, err := w.Write(data)
|
||||
return err
|
||||
}, indent, wrapAt)
|
||||
},
|
||||
"read": func(asset binAsset, indent string, wrapAt int) (string, error) {
|
||||
return writeWrappedString(asset.copy, indent, wrapAt)
|
||||
},
|
||||
"flate": func(asset binAsset, indent string, wrapAt int) (out string, err error) {
|
||||
return writeWrappedString(func(w io.Writer) error {
|
||||
fw, _ := flatePool.Get().(*flate.Writer)
|
||||
if fw != nil {
|
||||
fw.Reset(w)
|
||||
} else if fw, err = flate.NewWriter(w, flate.BestCompression); err != nil {
|
||||
return err
|
||||
}
|
||||
defer flatePool.Put(fw)
|
||||
|
||||
if err := asset.copy(fw); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return fw.Close()
|
||||
}, indent, wrapAt)
|
||||
},
|
||||
"format": formatTemplate,
|
||||
}).Parse(`
|
||||
{{- $unsafeRead := and (not $.Compress) (not $.MemCopy) -}}
|
||||
import (
|
||||
{{- if $.Compress}}
|
||||
"bytes"
|
||||
"compress/flate"
|
||||
"io"
|
||||
{{- end}}
|
||||
"os"
|
||||
"path/filepath"
|
||||
{{- if $unsafeRead}}
|
||||
"reflect"
|
||||
{{- end}}
|
||||
{{- if or $.Compress $.AssetDir}}
|
||||
"strings"
|
||||
{{- end}}
|
||||
{{- if and $.Compress $.DecompressOnce}}
|
||||
"sync"
|
||||
{{- end}}
|
||||
"time"
|
||||
{{- if $unsafeRead}}
|
||||
"unsafe"
|
||||
{{- end}}
|
||||
{{- if $.Restore}}
|
||||
|
||||
"github.com/tmthrgd/go-bindata/restore"
|
||||
{{- end}}
|
||||
)
|
||||
|
||||
{{if $unsafeRead -}}
|
||||
func bindataRead(data string) []byte {
|
||||
var empty [0]byte
|
||||
sx := (*reflect.StringHeader)(unsafe.Pointer(&data))
|
||||
b := empty[:]
|
||||
bx := (*reflect.SliceHeader)(unsafe.Pointer(&b))
|
||||
bx.Data = sx.Data
|
||||
bx.Len = len(data)
|
||||
bx.Cap = bx.Len
|
||||
return b
|
||||
}
|
||||
|
||||
{{end -}}
|
||||
|
||||
type asset struct {
|
||||
name string
|
||||
{{- if and $.Hash $.HashFormat}}
|
||||
orig string
|
||||
{{- end}}
|
||||
data string
|
||||
{{- if $.Compress}}
|
||||
size int64
|
||||
{{- end -}}
|
||||
{{- if and $.Metadata (not $.Mode)}}
|
||||
mode os.FileMode
|
||||
{{- end -}}
|
||||
{{- if and $.Metadata (not $.ModTime)}}
|
||||
time time.Time
|
||||
{{- end -}}
|
||||
{{- if $.Hash}}
|
||||
hash string
|
||||
{{- end}}
|
||||
{{- if and $.Compress $.DecompressOnce}}
|
||||
|
||||
once sync.Once
|
||||
bytes []byte
|
||||
err error
|
||||
{{- end}}
|
||||
}
|
||||
|
||||
func (a *asset) Name() string {
|
||||
return a.name
|
||||
}
|
||||
|
||||
func (a *asset) Size() int64 {
|
||||
{{- if $.Compress}}
|
||||
return a.size
|
||||
{{- else}}
|
||||
return int64(len(a.data))
|
||||
{{- end}}
|
||||
}
|
||||
|
||||
func (a *asset) Mode() os.FileMode {
|
||||
{{- if $.Mode}}
|
||||
return {{printf "%04o" $.Mode}}
|
||||
{{- else if $.Metadata}}
|
||||
return a.mode
|
||||
{{- else}}
|
||||
return 0
|
||||
{{- end}}
|
||||
}
|
||||
|
||||
func (a *asset) ModTime() time.Time {
|
||||
{{- if $.ModTime}}
|
||||
return time.Unix({{$.ModTime}}, 0)
|
||||
{{- else if $.Metadata}}
|
||||
return a.time
|
||||
{{- else}}
|
||||
return time.Time{}
|
||||
{{- end}}
|
||||
}
|
||||
|
||||
func (*asset) IsDir() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (*asset) Sys() interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
{{- if $.Hash}}
|
||||
|
||||
func (a *asset) OriginalName() string {
|
||||
{{- if $.HashFormat}}
|
||||
return a.orig
|
||||
{{- else}}
|
||||
return a.name
|
||||
{{- end}}
|
||||
}
|
||||
|
||||
func (a *asset) FileHash() []byte {
|
||||
{{- if $unsafeRead}}
|
||||
return bindataRead(a.hash)
|
||||
{{- else}}
|
||||
return []byte(a.hash)
|
||||
{{- end}}
|
||||
}
|
||||
|
||||
type FileInfo interface {
|
||||
os.FileInfo
|
||||
|
||||
OriginalName() string
|
||||
FileHash() []byte
|
||||
}
|
||||
{{- end}}
|
||||
|
||||
// _bindata is a table, holding each asset generator, mapped to its name.
|
||||
var _bindata = map[string]*asset{
|
||||
{{range $.Assets}} {{printf "%q" .Name}}: &asset{
|
||||
name: {{printf "%q" (base .Name)}},
|
||||
{{- if and $.Hash $.HashFormat}}
|
||||
orig: {{printf "%q" .File.Name}},
|
||||
{{- end}}
|
||||
data: {{if $.Compress -}}
|
||||
{{flate . "\t\t\t" 24}}
|
||||
{{- else -}}
|
||||
{{read . "\t\t\t" 24}}
|
||||
{{- end}},
|
||||
|
||||
{{- if or $.Metadata $.Compress -}}
|
||||
{{- $info := .Stat -}}
|
||||
|
||||
{{- if $.Compress}}
|
||||
size: {{$info.Size}},
|
||||
{{- end -}}
|
||||
|
||||
{{- if and $.Metadata (not $.Mode)}}
|
||||
mode: {{printf "%04o" $info.Mode}},
|
||||
{{- end -}}
|
||||
|
||||
{{- if and $.Metadata (not $.ModTime)}}
|
||||
{{$mod := $info.ModTime -}}
|
||||
time: time.Unix({{$mod.Unix}}, {{$mod.Nanosecond}}),
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if $.Hash}}
|
||||
hash: {{wrap .Hash "\t\t\t" 24}},
|
||||
{{- end}}
|
||||
},
|
||||
{{end -}}
|
||||
}
|
||||
|
||||
// AssetAndInfo loads and returns the asset and asset info for the
|
||||
// given name. It returns an error if the asset could not be found
|
||||
// or could not be loaded.
|
||||
func AssetAndInfo(name string) ([]byte, os.FileInfo, error) {
|
||||
a, ok := _bindata[filepath.ToSlash(name)]
|
||||
if !ok {
|
||||
return nil, nil, &os.PathError{Op: "open", Path: name, Err: os.ErrNotExist}
|
||||
}
|
||||
{{if and $.Compress $.DecompressOnce}}
|
||||
a.once.Do(func() {
|
||||
fr := flate.NewReader(strings.NewReader(a.data))
|
||||
|
||||
var buf bytes.Buffer
|
||||
if _, a.err = io.Copy(&buf, fr); a.err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if a.err = fr.Close(); a.err == nil {
|
||||
a.bytes = buf.Bytes()
|
||||
}
|
||||
})
|
||||
if a.err != nil {
|
||||
return nil, nil, &os.PathError{Op: "read", Path: name, Err: a.err}
|
||||
}
|
||||
|
||||
return a.bytes, a, nil
|
||||
{{- else if $.Compress}}
|
||||
fr := flate.NewReader(strings.NewReader(a.data))
|
||||
|
||||
var buf bytes.Buffer
|
||||
if _, err := io.Copy(&buf, fr); err != nil {
|
||||
return nil, nil, &os.PathError{Op: "read", Path: name, Err: err}
|
||||
}
|
||||
|
||||
if err := fr.Close(); err != nil {
|
||||
return nil, nil, &os.PathError{Op: "read", Path: name, Err: err}
|
||||
}
|
||||
|
||||
return buf.Bytes(), a, nil
|
||||
{{- else if $unsafeRead}}
|
||||
return bindataRead(a.data), a, nil
|
||||
{{- else}}
|
||||
return []byte(a.data), a, nil
|
||||
{{- end}}
|
||||
}
|
||||
|
||||
// AssetInfo loads and returns the asset info for the given name.
|
||||
// It returns an error if the asset could not be found or
|
||||
// could not be loaded.
|
||||
func AssetInfo(name string) (os.FileInfo, error) {
|
||||
a, ok := _bindata[filepath.ToSlash(name)]
|
||||
if !ok {
|
||||
return nil, &os.PathError{Op: "open", Path: name, Err: os.ErrNotExist}
|
||||
}
|
||||
|
||||
return a, nil
|
||||
}
|
||||
|
||||
{{- if and $.Hash $.HashFormat}}
|
||||
|
||||
{{format "hashnames" $}}
|
||||
|
||||
// AssetName returns the hashed name associated with an asset of a
|
||||
// given name.
|
||||
func AssetName(name string) (string, error) {
|
||||
if name, ok := _hashNames[filepath.ToSlash(name)]; ok {
|
||||
return name, nil
|
||||
}
|
||||
|
||||
return "", &os.PathError{Op: "open", Path: name, Err: os.ErrNotExist}
|
||||
}
|
||||
{{- end}}`)).New("hashnames").Parse(`
|
||||
var _hashNames = map[string]string{
|
||||
{{range .Assets -}}
|
||||
{{printf "%q" .File.Name}}: {{printf "%q" .Name}},
|
||||
{{end -}}
|
||||
}`))
|
||||
}
|
71
tools/vendor/github.com/tmthrgd/go-bindata/stringwriter.go
generated
vendored
Normal file
71
tools/vendor/github.com/tmthrgd/go-bindata/stringwriter.go
generated
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
// Copyright 2017 Tom Thorogood. All rights reserved.
|
||||
// Use of this source code is governed by a Modified
|
||||
// BSD License that can be found in the LICENSE file.
|
||||
|
||||
package bindata
|
||||
|
||||
import "io"
|
||||
|
||||
var (
|
||||
stringWriterLinePrefix = []byte(`"`)
|
||||
stringWriterLineSuffix = []byte("\" +\n")
|
||||
stringWriterParensLineSuffix = []byte("\") + (\"\" +\n")
|
||||
)
|
||||
|
||||
type stringWriter struct {
|
||||
io.Writer
|
||||
Indent string
|
||||
WrapAt int
|
||||
c, l int
|
||||
}
|
||||
|
||||
func (w *stringWriter) Write(p []byte) (n int, err error) {
|
||||
buf := [4]byte{'\\', 'x', 0, 0}
|
||||
|
||||
for _, b := range p {
|
||||
const lowerHex = "0123456789abcdef"
|
||||
buf[2] = lowerHex[b/16]
|
||||
buf[3] = lowerHex[b%16]
|
||||
|
||||
if _, err = w.Writer.Write(buf[:]); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
n++
|
||||
w.c++
|
||||
|
||||
if w.WrapAt == 0 || w.c%w.WrapAt != 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
w.l++
|
||||
|
||||
suffix := stringWriterLineSuffix
|
||||
if w.l%500 == 0 {
|
||||
// As per https://golang.org/issue/18078, the compiler has trouble
|
||||
// compiling the concatenation of many strings, s0 + s1 + s2 + ... + sN,
|
||||
// for large N. We insert redundant, explicit parentheses to work around
|
||||
// that, lowering the N at any given step: (s0 + s1 + ... + s499) + (s500 +
|
||||
// ... + s1999) + etc + (etc + ... + sN).
|
||||
//
|
||||
// This fix was taken from the fix applied to x/text in
|
||||
// https://github.com/golang/text/commit/5c6cf4f9a2.
|
||||
|
||||
suffix = stringWriterParensLineSuffix
|
||||
}
|
||||
|
||||
if _, err = w.Writer.Write(suffix); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if _, err = io.WriteString(w.Writer, w.Indent); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if _, err = w.Writer.Write(stringWriterLinePrefix); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
98
tools/vendor/github.com/tmthrgd/go-bindata/tree.go
generated
vendored
Normal file
98
tools/vendor/github.com/tmthrgd/go-bindata/tree.go
generated
vendored
Normal file
@@ -0,0 +1,98 @@
|
||||
// Copyright 2017 Tom Thorogood. All rights reserved.
|
||||
// Use of this source code is governed by a Modified
|
||||
// BSD License that can be found in the LICENSE file.
|
||||
|
||||
package bindata
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"text/template"
|
||||
)
|
||||
|
||||
type assetTree struct {
|
||||
Asset binAsset
|
||||
Children map[string]*assetTree
|
||||
Depth int
|
||||
}
|
||||
|
||||
func newAssetTree() *assetTree {
|
||||
return &assetTree{
|
||||
Children: make(map[string]*assetTree),
|
||||
}
|
||||
}
|
||||
|
||||
func (node *assetTree) child(name string) *assetTree {
|
||||
rv, ok := node.Children[name]
|
||||
if !ok {
|
||||
rv = newAssetTree()
|
||||
rv.Depth = node.Depth + 1
|
||||
node.Children[name] = rv
|
||||
}
|
||||
|
||||
return rv
|
||||
}
|
||||
|
||||
func init() {
|
||||
template.Must(template.Must(baseTemplate.New("tree").Funcs(template.FuncMap{
|
||||
"tree": func(toc []binAsset) *assetTree {
|
||||
tree := newAssetTree()
|
||||
for _, asset := range toc {
|
||||
node := tree
|
||||
for _, name := range strings.Split(asset.Name(), "/") {
|
||||
node = node.child(name)
|
||||
}
|
||||
|
||||
node.Asset = asset
|
||||
}
|
||||
|
||||
return tree
|
||||
},
|
||||
"format": formatTemplate,
|
||||
}).Parse(`// AssetDir returns the file names below a certain
|
||||
// directory embedded in the file by go-bindata.
|
||||
// For example if you run go-bindata on data/... and data contains the
|
||||
// following hierarchy:
|
||||
// data/
|
||||
// foo.txt
|
||||
// img/
|
||||
// a.png
|
||||
// b.png
|
||||
// then AssetDir("data") would return []string{"foo.txt", "img"}
|
||||
// AssetDir("data/img") would return []string{"a.png", "b.png"}
|
||||
// AssetDir("foo.txt") and AssetDir("notexist") would return an error
|
||||
// AssetDir("") will return []string{"data"}.
|
||||
func AssetDir(name string) ([]string, error) {
|
||||
node := _bintree
|
||||
|
||||
if name != "" {
|
||||
var ok bool
|
||||
for _, p := range strings.Split(filepath.ToSlash(name), "/") {
|
||||
if node, ok = node[p]; !ok {
|
||||
return nil, &os.PathError{Op: "open", Path: name, Err: os.ErrNotExist}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if len(node) == 0 {
|
||||
return nil, &os.PathError{Op: "open", Path: name, Err: os.ErrNotExist}
|
||||
}
|
||||
|
||||
rv := make([]string, 0, len(node))
|
||||
for name := range node {
|
||||
rv = append(rv, name)
|
||||
}
|
||||
|
||||
return rv, nil
|
||||
}
|
||||
|
||||
type bintree map[string]bintree
|
||||
|
||||
{{format "bintree" (tree .Assets)}}`)).New("bintree").Parse(`
|
||||
{{- if not .Depth -}}
|
||||
var _bintree = {{end -}}
|
||||
bintree{
|
||||
{{range $k, $v := .Children -}}
|
||||
{{printf "%q" $k}}: {{template "bintree" $v}},
|
||||
{{end -}}
|
||||
}`))
|
||||
}
|
Reference in New Issue
Block a user