This repository has been archived by the owner on Jun 25, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 196
/
deprecated.go
79 lines (68 loc) · 2.24 KB
/
deprecated.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
package packr
import (
"encoding/json"
"fmt"
"github.com/gobuffalo/packr/v2/file"
"github.com/gobuffalo/packr/v2/file/resolver"
"github.com/markbates/oncer"
)
// File has been deprecated and file.File should be used instead
type File = file.File
var (
// ErrResOutsideBox gets returned in case of the requested resources being outside the box
// Deprecated
ErrResOutsideBox = fmt.Errorf("can't find a resource outside the box")
)
// PackBytes packs bytes for a file into a box.
// Deprecated
func PackBytes(box string, name string, bb []byte) {
b := NewBox(box)
d := resolver.NewInMemory(map[string]file.File{})
f, err := file.NewFile(name, bb)
if err != nil {
panic(err)
}
if err := d.Pack(name, f); err != nil {
panic(err)
}
b.SetResolver(name, d)
}
// PackBytesGzip packets the gzipped compressed bytes into a box.
// Deprecated
func PackBytesGzip(box string, name string, bb []byte) error {
// TODO: this function never did what it was supposed to do!
PackBytes(box, name, bb)
return nil
}
// PackJSONBytes packs JSON encoded bytes for a file into a box.
// Deprecated
func PackJSONBytes(box string, name string, jbb string) error {
var bb []byte
err := json.Unmarshal([]byte(jbb), &bb)
if err != nil {
return err
}
PackBytes(box, name, bb)
return nil
}
// Bytes is deprecated. Use Find instead
func (b *Box) Bytes(name string) []byte {
bb, _ := b.Find(name)
oncer.Deprecate(0, "github.com/gobuffalo/packr/v2#Box.Bytes", "Use github.com/gobuffalo/packr/v2#Box.Find instead.")
return bb
}
// MustBytes is deprecated. Use Find instead.
func (b *Box) MustBytes(name string) ([]byte, error) {
oncer.Deprecate(0, "github.com/gobuffalo/packr/v2#Box.MustBytes", "Use github.com/gobuffalo/packr/v2#Box.Find instead.")
return b.Find(name)
}
// String is deprecated. Use FindString instead
func (b *Box) String(name string) string {
oncer.Deprecate(0, "github.com/gobuffalo/packr/v2#Box.String", "Use github.com/gobuffalo/packr/v2#Box.FindString instead.")
return string(b.Bytes(name))
}
// MustString is deprecated. Use FindString instead
func (b *Box) MustString(name string) (string, error) {
oncer.Deprecate(0, "github.com/gobuffalo/packr/v2#Box.MustString", "Use github.com/gobuffalo/packr/v2#Box.FindString instead.")
return b.FindString(name)
}