From b2cc117366269d6be83d2394189af5d206948b87 Mon Sep 17 00:00:00 2001 From: Roman Volosatovs Date: Wed, 25 Sep 2024 17:37:18 +0200 Subject: [PATCH] feat(go-examples): allow compilation with tinygo 0.33 Signed-off-by: Roman Volosatovs --- examples/go/http/http.go | 13 +------------ examples/go/http/http_test.go | 2 +- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/examples/go/http/http.go b/examples/go/http/http.go index d15e066..8f7a519 100644 --- a/examples/go/http/http.go +++ b/examples/go/http/http.go @@ -1,9 +1,8 @@ //go:generate go run github.com/bytecodealliance/wasm-tools-go/cmd/wit-bindgen-go generate -w app -o bindings ./wit -package app +package main import ( - "log/slog" "unsafe" "github.com/bytecodealliance/wasm-tools-go/cm" @@ -24,40 +23,30 @@ func ptr[T any](v T) *T { } func handle(req types.IncomingRequest, out types.ResponseOutparam) *types.ErrorCode { - slog.Debug("constructing new response") resp := types.NewOutgoingResponse(req.Headers()) - slog.Debug("getting response body") body := resp.Body() if body.IsErr() { - slog.Debug("failed to get response body") return ptr(types.ErrorCodeInternalError(cm.Some("failed to get response body"))) } bodyOut := body.OK() - slog.Debug("getting response body stream") bodyWrite := bodyOut.Write() if bodyWrite.IsErr() { - slog.Debug("failed to get response body stream") return ptr(types.ErrorCodeInternalError(cm.Some("failed to get response body stream"))) } - slog.Debug("setting response outparam") types.ResponseOutparamSet(out, cm.OK[cm.Result[types.ErrorCodeShape, types.OutgoingResponse, types.ErrorCode]](resp)) stream := bodyWrite.OK() s := "hello world" writeRes := stream.BlockingWriteAndFlush(cm.NewList(unsafe.StringData(s), uint(len(s)))) if writeRes.IsErr() { - slog.Error("failed to write to stream", "err", writeRes.Err()) return nil } - slog.Debug("dropping body stream") stream.ResourceDrop() - slog.Debug("finishing outgoing body") finishRes := types.OutgoingBodyFinish(*bodyOut, cm.None[types.Fields]()) if finishRes.IsErr() { - slog.Error("failed to finish outgoing body", "err", finishRes.Err()) return nil } return nil diff --git a/examples/go/http/http_test.go b/examples/go/http/http_test.go index cdee5fc..f93992c 100644 --- a/examples/go/http/http_test.go +++ b/examples/go/http/http_test.go @@ -1,6 +1,6 @@ //go:generate go run github.com/wasmCloud/wadge/cmd/wadge-bindgen-go -package app_test +package main_test import ( "io"