Created
August 1, 2020 10:28
-
-
Save spytheman/ab7a7c7eef78080a8006b7db8a28f7ed to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| import json | |
| struct User { name string age int } | |
| fn main(){ | |
| mut len := 0 | |
| C.read(0, &len, 4) | |
| if len > 1024 { panic('input too large') } | |
| mut buf := malloc(len) | |
| C.read(0, buf, len) | |
| s := string(buf, len) | |
| println('received s: $s') | |
| u := json.decode(User, s)? | |
| println('received user: $u') | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment