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

Function createVm

drive/script/utils.go:320–331  ·  view source on GitHub ↗
(ctx context.Context, config common.Config, script string)

Source from the content-addressed store, hash-verified

318}
319
320func createVm(ctx context.Context, config common.Config, script string) (*s.VM, error) {
321 scriptsPath, _ := config.GetDir(config.DrivesDir, false)
322 scriptBytes, e := os.ReadFile(filepath.Join(scriptsPath, script))
323 if e != nil {
324 return nil, e
325 }
326
327 vm := baseVM.Fork()
328
329 _, e = vm.Run(ctx, scriptBytes)
330 return vm, e
331}
332
333// wrapReader adapts an io.Reader into an io.ReadCloser. If reader already is a
334// ReadCloser it is returned as-is, otherwise a no-op Close is added.

Callers 3

newScriptDriveFunction · 0.85
initConfigFunction · 0.85
init_Function · 0.85

Calls 3

GetDirMethod · 0.80
ForkMethod · 0.80
RunMethod · 0.80

Tested by

no test coverage detected