mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
examples: add http.get and file writes to the coroutines example
This commit is contained in:
parent
54eabcb242
commit
f73e99cddd
@ -1,5 +1,5 @@
|
|||||||
// Build with
|
// Build with
|
||||||
// v -use-coroutines simple_coroutines.v
|
// v -gc none -use-coroutines simple_coroutines.v
|
||||||
//
|
//
|
||||||
import coroutines
|
import coroutines
|
||||||
import time
|
import time
|
||||||
@ -21,12 +21,11 @@ fn foo2(a int) {
|
|||||||
// C.printf(c'hello from foo2() a=%d\n', a)
|
// C.printf(c'hello from foo2() a=%d\n', a)
|
||||||
coroutines.sleep(2 * time.second)
|
coroutines.sleep(2 * time.second)
|
||||||
i++
|
i++
|
||||||
// resp := http.get('https://vlang.io/utc_now') or { panic(err) }
|
resp := http.get('https://vlang.io/utc_now') or { panic(err) }
|
||||||
// resp := http.get('http://example.com') or { panic(err) }
|
println(resp)
|
||||||
// println(resp)
|
mut f := os.create('/tmp/FOO2_a${i}') or { panic(err) }
|
||||||
// mut f := os.create('/tmp/FOO2_a${i}') or { panic(err) }
|
f.write_string(resp.body) or { panic(err) }
|
||||||
// f.write_string(resp.body) or { panic(err) }
|
f.close()
|
||||||
// f.close()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user