MCPcopy Create free account
hub / github.com/devld/go-drive / init

Method init

script/runtime.go:44–66  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

42}
43
44func (v *VM) init() error {
45 initVarsForVm(v)
46
47 // load scripts
48 entries, e := jsDir.ReadDir("js")
49 if e != nil {
50 return e
51 }
52 sort.Slice(entries, func(i, j int) bool {
53 return strings.Compare(entries[i].Name(), entries[j].Name()) < 0
54 })
55 for _, entry := range entries {
56 script, e := jsDir.ReadFile("js" + "/" + entry.Name())
57 if e != nil {
58 return e
59 }
60 if _, e := v.Run(context.Background(), script); e != nil {
61 return e
62 }
63 }
64
65 return nil
66}
67
68func (v *VM) Set(name string, value any) {
69 v.o.Set(name, value)

Callers 2

NewVMFunction · 0.95
49.dayjs.jsFile · 0.45

Calls 5

RunMethod · 0.95
initVarsForVmFunction · 0.85
SliceMethod · 0.65
NameMethod · 0.65
ReadDirMethod · 0.45

Tested by

no test coverage detected