From ba6d01449539190c59f4f9793d0ab67dca777a23 Mon Sep 17 00:00:00 2001 From: eltrac Date: Sun, 20 Sep 2026 14:58:22 +0800 Subject: go: finish wasm wrapper of microformats parser --- .gitignore | 3 +++ Makefile | 3 +++ go/main.go | 13 +++++++++---- 3 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 .gitignore create mode 100644 Makefile 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 + diff --git a/go/main.go b/go/main.go index 927e3f5..cecaa59 100644 --- a/go/main.go +++ b/go/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 } -- cgit v1.2.3