You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Golang is a popular programming language. Currently, you can compile Go apps to Wasm + WASI using TinyGo. The Go team will release a formal support for Wasm + WASI (preview1) in 1.21 (August 2023).
Golang can be compiled to WebAssembly, so there's no requirement of a language runtime like Python, Ruby or JavaScript. The goal for this task is to create the wrapper code to interact with Wasm Workers Server. The same approach we took for the Rust support.
Technical requirements
These are the for the Golang support:
Read the JSON metadata that comes via STDIN. Here you have the example from the Rust kit:
Define the Request, Response and Cache entities. If it's available, it's better to use primitives from the Golang standard library or common usage libraries.
Initialize a Request object from the JSON metadata.
Initialize the Cache store.
Call the worker function with the Request instance.
Detect the content in the response. If it's a valid UTF-8 string, we can return. If it uses a different encoding, you need to encode it in base64.
Transform the response and the Cache status into the expected JSON output. Note that the base64 flag is only enabled when the content is encoded.
That's amazing @mnafees! I assigned the task to you to keep track of it. I also updated the task to provide a better description of the requirements to complete it.
Please, feel free to ask any question and open a draft PR in case you want to share some early code for feedback. And thank you for your interest on contributing! 😄
Golang is a popular programming language. Currently, you can compile Go apps to Wasm + WASI using TinyGo. The Go team will release a formal support for Wasm + WASI (preview1) in 1.21 (August 2023).
Golang can be compiled to WebAssembly, so there's no requirement of a language runtime like Python, Ruby or JavaScript. The goal for this task is to create the wrapper code to interact with Wasm Workers Server. The same approach we took for the Rust support.
Technical requirements
These are the for the Golang support:
Read the JSON metadata that comes via STDIN. Here you have the example from the Rust kit:
wasm-workers-server/kits/rust/src/io.rs
Lines 15 to 23 in 5631fb4
Define the
Request
,Response
andCache
entities. If it's available, it's better to use primitives from the Golang standard library or common usage libraries.Initialize a
Request
object from the JSON metadata.Initialize the Cache store.
Call the worker function with the
Request
instance.Detect the content in the response. If it's a valid UTF-8 string, we can return. If it uses a different encoding, you need to encode it in base64.
Transform the response and the Cache status into the expected JSON output. Note that the
base64
flag is only enabled when the content is encoded.wasm-workers-server/kits/rust/src/io.rs
Lines 59 to 65 in 5631fb4
Print the JSON output via STDOUT
Additional notes
kits/go
folder.The text was updated successfully, but these errors were encountered: