diff options
| author | eltrac <hi@eltr.ac> | 2026-09-20 14:58:22 +0800 |
|---|---|---|
| committer | eltrac <hi@eltr.ac> | 2026-09-20 14:58:22 +0800 |
| commit | ba6d01449539190c59f4f9793d0ab67dca777a23 (patch) | |
| tree | 1c670398cd987788584ce3bad6ae44d59ddf1507 | |
| parent | 53099a05cd3a30dbefc6d87fca003ed28a7ddbad (diff) | |
go: finish wasm wrapper of microformats parser
| -rw-r--r-- | .gitignore | 3 | ||||
| -rw-r--r-- | Makefile | 3 | ||||
| -rw-r--r-- | go/main.go | 13 |
3 files changed, 15 insertions, 4 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6572aed --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +/.clj-kondo/.cache/v1 +/.lsp/.cache +/resources/mf2go.wasm diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..5f54d8c --- /dev/null +++ b/Makefile @@ -0,0 +1,3 @@ +build-wasm:
+ @cd go && tinygo build -o ../resources/mf2go.wasm -target wasip1 -buildmode=c-shared main.go
+
@@ -1,13 +1,18 @@ package main import ( + "bytes" + "github.com/extism/go-pdk" + "willnorris.com/go/microformats" ) -//go:wasmexport greet -func greet() int32 { +//go:wasmexport parse +func parse() int32 { input := pdk.Input() - greeting := `Hello, ` + string(input) + `!` - pdk.OutputString(greeting) + r := bytes.NewReader(input) + data := microformats.Parse(r, nil) + + pdk.OutputJSON(data) return 0 } |
