This repository has been archived by the owner on Jul 14, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
embeds.go
68 lines (61 loc) · 3.78 KB
/
embeds.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
package internal
import (
"encoding/base64"
"sort"
)
const (
file696e7465726e616c2f74657374646174612f6d6967726174696f6e732f30315f746573742e646f776e2e73716c = "LS0gcmVxdWlyZWQgYnkgbWlncmF0ZS9kcml2ZXJfdGVzdC5nbw"
file696e7465726e616c2f74657374646174612f6d6967726174696f6e732f30315f746573742e75702e73716c = "LS0gcmVxdWlyZWQgYnkgbWlncmF0ZS9kcml2ZXJfdGVzdC5nbw"
file696e7465726e616c2f74657374646174612f6d6967726174696f6e732f30335f746573742e75702e73716c = "LS0gcmVxdWlyZWQgYnkgbWlncmF0ZS9kcml2ZXJfdGVzdC5nbw"
file696e7465726e616c2f74657374646174612f6d6967726174696f6e732f30345f746573742e646f776e2e73716c = "LS0gcmVxdWlyZWQgYnkgbWlncmF0ZS9kcml2ZXJfdGVzdC5nbw"
file696e7465726e616c2f74657374646174612f6d6967726174696f6e732f30345f746573742e75702e73716c = "LS0gcmVxdWlyZWQgYnkgbWlncmF0ZS9kcml2ZXJfdGVzdC5nbw"
file696e7465726e616c2f74657374646174612f6d6967726174696f6e732f30355f746573742e646f776e2e73716c = "LS0gcmVxdWlyZWQgYnkgbWlncmF0ZS9kcml2ZXJfdGVzdC5nbw"
file696e7465726e616c2f74657374646174612f6d6967726174696f6e732f30375f746573742e646f776e2e73716c = "LS0gcmVxdWlyZWQgYnkgbWlncmF0ZS9kcml2ZXJfdGVzdC5nbw"
file696e7465726e616c2f74657374646174612f6d6967726174696f6e732f30375f746573742e75702e73716c = "LS0gcmVxdWlyZWQgYnkgbWlncmF0ZS9kcml2ZXJfdGVzdC5nbw"
file696e7465726e616c2f74657374646174612f72616e646f6d2e626c6f62 = "3CQYyKA3iE4lm46sD3rTPRIHw0A979F1zLmlVKboISIgBs0Ud2Ujg0DmAAgbX44PM8husHKdJt/e7dOEMA8gbztR2UabrVO1yDg5IJrsLm9vs3lEXsTdR1Is0HVrRLz5VRyJrVtQZYQEE7jRBvAcG9VCU9o7ok+KVf0cEQnW4SE"
file696e7465726e616c2f74657374646174612f746573742e6a736f6e = "eyJtZXNzYWdlIjogIkhlbGxvLCBXb3JsZCEifQo"
)
// Embedded implements github.com/klingtnet/embed/Embed .
type Embedded struct {
embedMap map[string]string
}
// Embeds stores the embedded data.
var Embeds = Embedded{
embedMap: map[string]string{
"internal/testdata/migrations/01_test.down.sql": file696e7465726e616c2f74657374646174612f6d6967726174696f6e732f30315f746573742e646f776e2e73716c,
"internal/testdata/migrations/01_test.up.sql": file696e7465726e616c2f74657374646174612f6d6967726174696f6e732f30315f746573742e75702e73716c,
"internal/testdata/migrations/03_test.up.sql": file696e7465726e616c2f74657374646174612f6d6967726174696f6e732f30335f746573742e75702e73716c,
"internal/testdata/migrations/04_test.down.sql": file696e7465726e616c2f74657374646174612f6d6967726174696f6e732f30345f746573742e646f776e2e73716c,
"internal/testdata/migrations/04_test.up.sql": file696e7465726e616c2f74657374646174612f6d6967726174696f6e732f30345f746573742e75702e73716c,
"internal/testdata/migrations/05_test.down.sql": file696e7465726e616c2f74657374646174612f6d6967726174696f6e732f30355f746573742e646f776e2e73716c,
"internal/testdata/migrations/07_test.down.sql": file696e7465726e616c2f74657374646174612f6d6967726174696f6e732f30375f746573742e646f776e2e73716c,
"internal/testdata/migrations/07_test.up.sql": file696e7465726e616c2f74657374646174612f6d6967726174696f6e732f30375f746573742e75702e73716c,
"internal/testdata/random.blob": file696e7465726e616c2f74657374646174612f72616e646f6d2e626c6f62,
"internal/testdata/test.json": file696e7465726e616c2f74657374646174612f746573742e6a736f6e,
},
}
// Files implements github.com/klingtnet/embed/Embed .
func (e Embedded) Files() []string {
var fs []string
for f := range e.embedMap {
fs = append(fs, f)
}
sort.Strings(fs)
return fs
}
// File implements github.com/klingtnet/embed/Embed .
func (e Embedded) File(path string) []byte {
file, ok := e.embedMap[path]
if !ok {
return nil
}
d, err := base64.RawStdEncoding.DecodeString(file)
if err != nil {
panic(err)
}
return d
}
// FileString implements github.com/klingtnet/embed/Embed .
func (e Embedded) FileString(path string) string {
return string(e.File(path))
}