MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime-go / NewModuleFromFile

Function NewModuleFromFile

module_feats_cranelift_wat.go:9–23  ·  view source on GitHub ↗

NewModuleFromFile reads the contents of the `file` provided and interprets them as either the text format or the binary format for WebAssembly. Afterwards delegates to the `NewModule` constructor with the contents read.

(engine *Engine, file string)

Source from the content-addressed store, hash-verified

7//
8// Afterwards delegates to the `NewModule` constructor with the contents read.
9func NewModuleFromFile(engine *Engine, file string) (*Module, error) {
10 wasm, err := os.ReadFile(file)
11 if err != nil {
12 return nil, err
13 }
14 // If this wasm isn't actually wasm, treat it as the text format and
15 // parse it as such.
16 if len(wasm) > 0 && wasm[0] != 0 {
17 wasm, err = Wat2Wasm(string(wasm))
18 if err != nil {
19 return nil, err
20 }
21 }
22 return NewModule(engine, wasm)
23}

Callers

nothing calls this directly

Calls 2

Wat2WasmFunction · 0.85
NewModuleFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…