Add structured coroutines and explicit error handling

This commit is contained in:
pavel 2026-08-27 16:26:40 +02:00
commit fe62e81152
31 changed files with 1701 additions and 325 deletions

View file

@ -12,7 +12,7 @@ package demo
import json encoding.json
fun decode(body: ByteSlice): List<Account> {
val accounts = json.decode<List<Account>>(body)
val accounts = json.decode<List<Account>>(body).unwrap()
return accounts
}
`)
@ -23,7 +23,7 @@ fun decode(body: ByteSlice): List<Account> {
if err != nil {
t.Fatalf("generation failed: %v", err)
}
for _, want := range []string{"accounts := gotlinAutoThrow(gotlinJSONDecode[[]Account](body))", "json.Unmarshal(body, &value)"} {
for _, want := range []string{"accounts := gotlinResultUnwrap(gotlinJSONDecode[[]Account](body))", "json.Unmarshal(body, &value)"} {
if !strings.Contains(string(out), want) {
t.Fatalf("generated Go missing %q:\n%s", want, out)
}