1package bindata
2
3const tmplImport string = `
4import (
5	"os"
6	"time"
7)
8
9`
10
11const tmplImportCompressNomemcopy = `
12import (
13	"bytes"
14	"compress/gzip"
15	"fmt"
16	"io"
17	"io/ioutil"
18	"os"
19	"path/filepath"
20	"strings"
21	"time"
22)
23
24func bindataRead(data, name string) ([]byte, error) {
25	gz, err := gzip.NewReader(strings.NewReader(data))
26	if err != nil {
27		return nil, fmt.Errorf("Read %q: %v", name, err)
28	}
29
30	var buf bytes.Buffer
31	_, err = io.Copy(&buf, gz)
32	clErr := gz.Close()
33
34	if err != nil {
35		return nil, fmt.Errorf("Read %q: %v", name, err)
36	}
37	if clErr != nil {
38		return nil, err
39	}
40
41	return buf.Bytes(), nil
42}
43
44`
45
46const tmplImportCompressMemcopy = `
47import (
48	"bytes"
49	"compress/gzip"
50	"fmt"
51	"io"
52	"io/ioutil"
53	"os"
54	"path/filepath"
55	"strings"
56	"time"
57)
58
59func bindataRead(data []byte, name string) ([]byte, error) {
60	gz, err := gzip.NewReader(bytes.NewBuffer(data))
61	if err != nil {
62		return nil, fmt.Errorf("Read %q: %v", name, err)
63	}
64
65	var buf bytes.Buffer
66	_, err = io.Copy(&buf, gz)
67	clErr := gz.Close()
68
69	if err != nil {
70		return nil, fmt.Errorf("Read %q: %v", name, err)
71	}
72	if clErr != nil {
73		return nil, err
74	}
75
76	return buf.Bytes(), nil
77}
78
79`
80
81const tmplImportNocompressNomemcopy = `
82import (
83	"fmt"
84	"io/ioutil"
85	"os"
86	"path/filepath"
87	"reflect"
88	"strings"
89	"time"
90	"unsafe"
91)
92
93// nolint: deadcode, gas
94func bindataRead(data, name string) ([]byte, error) {
95	var empty [0]byte
96	sx := (*reflect.StringHeader)(unsafe.Pointer(&data))
97	b := empty[:]
98	bx := (*reflect.SliceHeader)(unsafe.Pointer(&b))
99	bx.Data = sx.Data
100	bx.Len = len(data)
101	bx.Cap = bx.Len
102	return b, nil
103}
104
105`
106
107const tmplImportNocompressMemcopy = `
108import (
109	"fmt"
110	"io/ioutil"
111	"os"
112	"path/filepath"
113	"strings"
114	"time"
115)
116
117`
118
119const tmplReleaseHeader = `
120type asset struct {
121	bytes []byte
122	info  fileInfoEx
123}
124
125type fileInfoEx interface {
126	os.FileInfo
127	MD5Checksum() string
128}
129
130type bindataFileInfo struct {
131	name        string
132	size        int64
133	mode        os.FileMode
134	modTime     time.Time
135	md5checksum string
136}
137
138func (fi bindataFileInfo) Name() string {
139	return fi.name
140}
141func (fi bindataFileInfo) Size() int64 {
142	return fi.size
143}
144func (fi bindataFileInfo) Mode() os.FileMode {
145	return fi.mode
146}
147func (fi bindataFileInfo) ModTime() time.Time {
148	return fi.modTime
149}
150func (fi bindataFileInfo) MD5Checksum() string {
151	return fi.md5checksum
152}
153func (fi bindataFileInfo) IsDir() bool {
154	return false
155}
156func (fi bindataFileInfo) Sys() interface{} {
157	return nil
158}
159
160`
161
162const tmplFuncCompressNomemcopy string = `"
163
164func %sBytes() ([]byte, error) {
165	return bindataRead(
166		_%s,
167		%q,
168	)
169}
170
171`
172
173const tmplFuncCompressMemcopy string = `")
174
175func %sBytes() ([]byte, error) {
176	return bindataRead(
177		_%s,
178		%q,
179	)
180}
181
182`
183
184const tmplFuncNocompressNomemcopy string = `"
185
186func %sBytes() ([]byte, error) {
187	return bindataRead(
188		_%s,
189		%q,
190	)
191}
192
193`
194
195const tmplFuncNocompressMemcopy string = `)
196
197func %sBytes() ([]byte, error) {
198	return _%s, nil
199}
200
201`
202
203const tmplReleaseCommon string = `
204
205func %s() (*asset, error) {
206	bytes, err := %sBytes()
207	if err != nil {
208		return nil, err
209	}
210
211	info := bindataFileInfo{
212		name: %q,
213		size: %d,
214		md5checksum: %q,
215		mode: os.FileMode(%d),
216		modTime: time.Unix(%d, 0),
217	}
218
219	a := &asset{bytes: bytes, info: info}
220
221	return a, nil
222}
223
224`
225