-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
575 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,3 +20,4 @@ tmp | |
site | ||
slingshot.code-workspace | ||
|
||
linux |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"editor.fontSize": 16, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
*.wasm | ||
slingshot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
version: '3' | ||
|
||
description: > | ||
task slingshot-build | ||
task wasm-build | ||
task wasm-run | ||
tasks: | ||
# task slingshot-build | ||
slingshot-build: | ||
cmds: | ||
- | | ||
target=$(pwd) | ||
cd ../../../slingshot-server | ||
env CGO_ENABLED=0 go build -ldflags="-s -w" -o ${target}/slingshot | ||
# task wasm-build | ||
wasm-build: | ||
cmds: | ||
- | | ||
tinygo build -scheduler=none --no-debug \ | ||
-o input.wasm \ | ||
-target wasi main.go | ||
ls -lh *.wasm | ||
# task wasm-run | ||
wasm-run: | ||
cmds: | ||
- | | ||
./slingshot run --wasm=./input.wasm --handler=callHandler | ||
# task all | ||
all: | ||
cmds: | ||
- task slingshot-build | ||
- task wasm-build | ||
- task wasm-run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module input-string | ||
|
||
go 1.20 | ||
|
||
require github.com/extism/go-pdk v0.0.0-20230816024928-ee09fee7466e // indirect | ||
|
||
require github.com/valyala/fastjson v1.6.4 // indirect | ||
|
||
require github.com/bots-garden/slingshot/go-pdk v0.0.0 | ||
|
||
replace github.com/bots-garden/slingshot/go-pdk => ../../../go-pdk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
github.com/extism/go-pdk v0.0.0-20230816024928-ee09fee7466e h1:y6pBlzMRaYEBriiyzmT8e82927vBpum357VWi7Lg3/U= | ||
github.com/extism/go-pdk v0.0.0-20230816024928-ee09fee7466e/go.mod h1:3qe+ObKvmOVwzmQDC5A7KzTuvfjImOnWsB1MWU6mWA4= | ||
github.com/valyala/fastjson v1.6.3 h1:tAKFnnwmeMGPbwJ7IwxcTPCNr3uIzoIj3/Fh90ra4xc= | ||
github.com/valyala/fastjson v1.6.4 h1:uAUNq9Z6ymTgGhcm0UynUAB6tlbakBrz6CQFax3BXVQ= | ||
github.com/valyala/fastjson v1.6.4/go.mod h1:CLCAqky6SMuOcxStkYQvblddUtoRxhYMGLrsQns1aXY= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package main | ||
|
||
import ( | ||
slingshot "github.com/bots-garden/slingshot/go-pdk" | ||
) | ||
|
||
func helloHandler(argHandler []byte) { | ||
|
||
name := slingshot.Input("π€ What's your name? > ") | ||
|
||
slingshot.Println("π Hello " + name + " π") | ||
|
||
} | ||
|
||
//export callHandler | ||
func callHandler() { | ||
slingshot.ExecVoidHandler(helloHandler) | ||
} | ||
|
||
func main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
*.wasm | ||
slingshot | ||
*.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
version: '3' | ||
|
||
description: > | ||
task slingshot-build | ||
task wasm-build | ||
task wasm-run | ||
tasks: | ||
# task slingshot-build | ||
slingshot-build: | ||
cmds: | ||
- | | ||
target=$(pwd) | ||
cd ../../../slingshot-server | ||
env CGO_ENABLED=0 go build -ldflags="-s -w" -o ${target}/slingshot | ||
# task wasm-build | ||
wasm-build: | ||
cmds: | ||
- | | ||
tinygo build -scheduler=none --no-debug \ | ||
-o input.wasm \ | ||
-target wasi main.go | ||
ls -lh *.wasm | ||
# task wasm-run | ||
wasm-run: | ||
cmds: | ||
- | | ||
./slingshot run --wasm=./input.wasm --handler=hello | ||
# task all | ||
all: | ||
cmds: | ||
- task slingshot-build | ||
- task wasm-build | ||
- task wasm-run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module input-string | ||
|
||
go 1.20 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/extism/go-pdk" | ||
) | ||
|
||
//export hostPrintln | ||
func hostPrintln(offset uint64) uint64 | ||
|
||
func Println(text string) { | ||
memoryText := pdk.AllocateString(text) | ||
hostPrintln(memoryText.Offset()) | ||
} | ||
|
||
//export hostInput | ||
func hostInput(offset uint64) uint64 | ||
|
||
func Input(prompt string) string { | ||
promptMemory := pdk.AllocateString(prompt) | ||
offset := hostInput(promptMemory.Offset()) | ||
|
||
memoryResult := pdk.FindMemory(offset) | ||
buffResult := make([]byte, memoryResult.Length()) | ||
memoryResult.Load(buffResult) | ||
|
||
return string(buffResult) | ||
} | ||
|
||
//export hello | ||
func hello() { | ||
name := Input("π€ Name? > ") | ||
Println("π Hello " + name + " π") | ||
|
||
} | ||
|
||
func main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ use ( | |
./09-nats-pub | ||
./10-read | ||
./11-write | ||
./12-input-string | ||
) | ||
|
||
// go work sync |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
*.wasm | ||
slingshot* | ||
target | ||
index.html |
Oops, something went wrong.