examples/

directory
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 12, 2026 License: MIT

README

Sherlock WASI and WASM examples

This folder contains two runnable examples:

  • examples/wasi: CLI program compiled for wasip1/wasm
  • examples/wasm: browser-facing js/wasm module exposing sherlockDetectBase64

1) WASI example (wasip1/wasm)

Build:

GOOS=wasip1 GOARCH=wasm go build -o examples/wasi/wasi-detect.wasm ./examples/wasi

Run with a WASI runtime (example: wasmtime):

wasmtime run --dir=. examples/wasi/wasi-detect.wasm -- ./some-file.pdf

The program prints JSON metadata to stdout.

2) Browser WASM example (js/wasm)

Build the wasm binary:

GOOS=js GOARCH=wasm go build -o examples/wasm/app.wasm ./examples/wasm

Copy Go runtime support file:

cp "$(go env GOROOT)/lib/wasm/wasm_exec.js" examples/wasm/

Serve the folder locally (any static server works), for example:

python3 -m http.server 8080 --directory examples/wasm

Open http://localhost:8080, choose a file, and inspect detector output.

JS API exposed by the WASM module

  • globalThis.sherlockDetectBase64(base64Content): string
  • Returns a JSON string with metadata (or an error field)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL