This repository has been archived by the owner on Aug 21, 2020. It is now read-only.
/
debug.go
84 lines (70 loc) · 1.93 KB
/
debug.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
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 -}}
}`))
}