Skip to content

feat(plugin): support native Go plugins with WASI (wasip1)#71

Merged
knqyf263 merged 4 commits intomainfrom
go_124
Mar 11, 2025
Merged

feat(plugin): support native Go plugins with WASI (wasip1)#71
knqyf263 merged 4 commits intomainfrom
go_124

Conversation

@knqyf263
Copy link
Owner

@knqyf263 knqyf263 commented Mar 9, 2025

Overview

This PR updates the plugin system to support native Go plugins using WASI (wasip1) instead of relying on TinyGo. With Go 1.24+, we can now compile Go code directly to WebAssembly with WASI reactor support, eliminating the need for TinyGo as an intermediate compiler.

Description

Go 1.24 introduced improved WebAssembly support with the reactor and //go:wasmexport support, allowing us to compile Go code directly to Wasm. This PR makes the following changes:

  • Remove TinyGo dependency and related build configurations
  • Update build commands from tinygo build to GOOS=wasip1 GOARCH=wasm go build
  • Change build tags from tinygo.wasm to wasip1
  • Update export annotations from //export to //go:wasmexport
  • Update documentation to reflect the new Go-based approach
  • Set Go 1.24+ as a requirement
  • Update CI workflow to remove TinyGo-specific testing

These changes simplify the plugin development process by allowing developers to use the standard Go toolchain without requiring TinyGo, while maintaining all the benefits of WebAssembly-based plugins.

knqyf263 added 2 commits March 9, 2025 16:00
- Upgrade Go version from 1.22 to 1.24.0
- Update wazero dependency from v1.7.0 to v1.9.0
- Update corresponding go.sum entries
This commit updates the project to use standard Go's WebAssembly support instead of TinyGo:

- Replace TinyGo-specific build constraints with `wasip1`
- Update Makefile to use standard Go Wasm compilation
- Modify plugin initialization to use `init()` instead of `main()`
- Update memory management functions
- Replace `//export` with `//go:wasmexport`
- Update README and documentation references
- Regenerate protobuf files with updated protoc version

The changes enable broader compatibility with Go's native Wasm support while maintaining the existing plugin architecture.
@knqyf263 knqyf263 self-assigned this Mar 9, 2025
…parsing

This commit adds a new test case for a WebAssembly plugin using standard Go's JSON parsing and host function capabilities:

- Implement a new test function `TestStd` in host_functions_test.go
- Create a new plugin implementation in plugin-std/plugin.go
- Demonstrate JSON unmarshaling and string formatting in a Wasm plugin
- Use `WithStdout` to enable standard output handling
- Verify plugin interaction with a sample greeting scenario
@knqyf263 knqyf263 marked this pull request as ready for review March 10, 2025 03:49
Clean up README by removing outdated JSON parsing notes specific to TinyGo, including:
- Remove section about JSON parsing limitations
- Delete links to JSON parsing libraries
- Remove reference to JSON parsing example link
@knqyf263 knqyf263 merged commit c156889 into main Mar 11, 2025
1 check passed
@knqyf263 knqyf263 deleted the go_124 branch March 11, 2025 05:42
thaJeztah referenced this pull request in containerd/nri Aug 25, 2025
Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
Signed-off-by: Krisztian Litkey <krisztian.litkey@intel.com>
Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant