Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support EXTISM_ENABLE_WASI_OUTPUT #51

Merged
merged 4 commits into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions extism.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,11 @@ func NewPlugin(
// See: https://github.com/extism/go-sdk/pull/1#issuecomment-1650527495
moduleConfig = moduleConfig.WithStartFunctions().WithFSConfig(fs)

_, wasiOutput := os.LookupEnv("EXTISM_ENABLE_WASI_OUTPUT")
if c.hasWasi && wasiOutput {
moduleConfig = moduleConfig.WithStderr(os.Stderr).WithStdout(os.Stdout)
}

// Try to find the main module:
// - There is always one main module
// - If a Wasm value has the Name field set to "main" then use that module
Expand Down
10 changes: 10 additions & 0 deletions plugins/println/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module github.com/extism/extism-sdk-plugins-println

go 1.21.0

toolchain go1.21.1

require (
github.com/extism/go-pdk v1.0.0-rc2 // indirect
github.com/valyala/fastjson v1.6.3 // indirect
)
8 changes: 8 additions & 0 deletions plugins/println/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
github.com/extism/go-pdk v0.0.0-20230119214914-65bffbeb3e64 h1:IfR1k741q+yQLvv5sLShCkvt3FgKU4wQVJfp7hhb/iY=
github.com/extism/go-pdk v0.0.0-20230119214914-65bffbeb3e64/go.mod h1:1wdiAoG8306g4WK+6laBrS+75089/0V4XRVTllt8b5U=
github.com/extism/go-pdk v1.0.0-rc1.0.20231019212020-62d54a6e0263 h1:uSo+K1JhsMlamDmaxyAGj0dGExZHLsL+Edyug0dC+uk=
github.com/extism/go-pdk v1.0.0-rc1.0.20231019212020-62d54a6e0263/go.mod h1:Gz+LIU/YCKnKXhgge8yo5Yu1F/lbv7KtKFkiCSzW/P4=
github.com/extism/go-pdk v1.0.0-rc2 h1:EZuo8idErnV8KB8TTSTiO2T1lkX047OQ7K8STjn2WBs=
github.com/extism/go-pdk v1.0.0-rc2/go.mod h1:Gz+LIU/YCKnKXhgge8yo5Yu1F/lbv7KtKFkiCSzW/P4=
github.com/valyala/fastjson v1.6.3 h1:tAKFnnwmeMGPbwJ7IwxcTPCNr3uIzoIj3/Fh90ra4xc=
github.com/valyala/fastjson v1.6.3/go.mod h1:CLCAqky6SMuOcxStkYQvblddUtoRxhYMGLrsQns1aXY=
16 changes: 16 additions & 0 deletions plugins/println/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package main

import (
"fmt"

pdk "github.com/extism/go-pdk"
)

//export run_test
func run_test() int32 {
input := pdk.InputString()
fmt.Println("this was printed from the plugin", input)
return 0
}

func main() {}
Binary file added wasm/println.wasm
Binary file not shown.