-
Notifications
You must be signed in to change notification settings - Fork 66
/
resData.go
46 lines (35 loc) · 869 Bytes
/
resData.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
package deeptest
import (
"embed"
commonUtils "github.com/deeptest-com/deeptest/pkg/lib/comm"
_logUtils "github.com/deeptest-com/deeptest/pkg/lib/log"
"os"
"path/filepath"
)
//go:embed res
var resFileSys embed.FS
func ReadResData(pth string) (ret []byte, err error) {
if commonUtils.IsRelease() {
ret, err = resFileSys.ReadFile(pth)
} else {
ret, err = os.ReadFile(pth)
}
return
}
//go:embed internal/agent/_prompt_templ
var promptFileSys embed.FS
func ReadPromptTempl(pth string) (ret string, err error) {
var bytes []byte
if commonUtils.IsRelease() {
bytes, err = promptFileSys.ReadFile(pth)
} else {
currentPath, _ := os.Getwd()
fullPath := filepath.Join(currentPath, "internal", "agent", "_prompt_templ", pth)
bytes, err = os.ReadFile(fullPath)
}
if err != nil {
_logUtils.Infof(err.Error())
}
ret = string(bytes)
return
}