Add structured coroutines and explicit error handling
This commit is contained in:
parent
de1262b4cf
commit
fe62e81152
31 changed files with 1701 additions and 325 deletions
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue