forked from thrasher-corp/gocryptotrader
-
Notifications
You must be signed in to change notification settings - Fork 1
/
loader.go
44 lines (38 loc) · 1.08 KB
/
loader.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
package loader
import (
"github.com/d5/tengo/v2"
"github.com/d5/tengo/v2/stdlib"
"github.com/idoall/gocryptotrader/gctscript/modules/gct"
"github.com/idoall/gocryptotrader/gctscript/modules/ta"
)
// GetModuleMap returns the module map that includes all modules
// for the given module names.
func GetModuleMap() *tengo.ModuleMap {
modules := tengo.NewModuleMap()
gctModuleList := gct.AllModuleNames()
for _, name := range gctModuleList {
if mod := gct.Modules[name]; mod != nil {
modules.AddBuiltinModule(name, mod)
}
}
taModuleList := ta.AllModuleNames()
for _, name := range taModuleList {
if mod := ta.Modules[name]; mod != nil {
modules.AddBuiltinModule(name, mod)
}
}
stdLib := stdlib.AllModuleNames()
for _, name := range stdLib {
if mod := stdlib.BuiltinModules[name]; mod != nil {
modules.AddBuiltinModule(name, mod)
}
if mod := stdlib.SourceModules[name]; mod != "" {
modules.AddSourceModule(name, []byte(mod))
}
}
return modules
}
// SetDefaultScriptOutput sets the output folder
func SetDefaultScriptOutput(path string) {
gct.OutputDir = path
}