-
Notifications
You must be signed in to change notification settings - Fork 0
/
boxes.go
52 lines (38 loc) · 1.3 KB
/
boxes.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
/*
Package boxes is a wrapper around a set of go.rice boxes created by a go.rice Config
defined to first look for files in the package directory, and then in the binary.
*/
package app
import rice "github.com/GeertJohan/go.rice"
//go:generate rice clean
//go:generate rice embed-go
// reference: https://github.com/yext/revere/blob/master/boxes/boxes.go
// There are some odd things in this package due to how go.rice's rice tool
// works. In order to generate the appropriate go files, the tool must go
// through this package and find all calls to FindBox (and MustFindBox) to
// figure out which directories need to be put into "Boxes".
// go.rice idiosyncrasy #1 - The package name variable must shadow the Config
// (if a rice.Config is used) in order for the rice tool to pick up calls to FindBox.
// go.rice idiosyncrasy #2 - Calls to FindBox must be done with string literals.
var assets *rice.Box
func Assets() *rice.Box {
if assets != nil {
return assets
}
assets = rice.MustFindBox("../ui/dist")
return assets
}
func GetAppConfBytes() []byte {
bytes, err := rice.MustFindBox("../conf").Bytes("app.yaml")
if err != nil {
panic(err)
}
return bytes
}
func GetLogConfBytes() []byte {
bytes, err := rice.MustFindBox("../conf").Bytes("log.yaml")
if err != nil {
panic(err)
}
return bytes
}