1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

all: require calling optfn() ? / optfn() or {...} for fn optfn() ? {}

This commit is contained in:
Delyan Angelov
2021-01-26 16:43:10 +02:00
parent 97103f680a
commit e5a84719ca
90 changed files with 1994 additions and 1832 deletions

View File

@@ -99,7 +99,7 @@ fn (am AssetManager) combine(asset_type string, to_file bool) string {
os.mkdir(am.cache_dir) or { panic(err) }
}
mut file := os.create(out_file) or { panic(err) }
file.write(out.bytes())
file.write(out.bytes()) or { panic(err) }
file.close()
return out_file
}

View File

@@ -6,7 +6,7 @@ import os
// unique cache dirs are needed per test function.
fn clean_cache_dir(dir string) {
if os.is_dir(dir) {
os.rmdir_all(dir)
os.rmdir_all(dir) or { panic(err) }
}
}
@@ -21,10 +21,10 @@ fn cache_dir(test_name string) string {
fn get_test_file_path(file string) string {
path := os.join_path(base_cache_dir(), file)
if !os.is_dir(base_cache_dir()) {
os.mkdir_all(base_cache_dir())
os.mkdir_all(base_cache_dir()) or { panic(err) }
}
if !os.exists(path) {
os.write_file(path, get_test_file_contents(file))
os.write_file(path, get_test_file_contents(file)) or { panic(err) }
}
return path
}

View File

@@ -20,7 +20,7 @@ const (
fn testsuite_begin() {
os.chdir(vroot)
if os.exists(serverexe) {
os.rm(serverexe)
os.rm(serverexe) or { }
}
}
@@ -246,7 +246,7 @@ fn simple_tcp_client(config SimpleTcpClientConfig) ?string {
client.set_read_timeout(tcp_r_timeout)
client.set_write_timeout(tcp_w_timeout)
defer {
client.close()
client.close() or { }
}
message := 'GET $config.path HTTP/1.1
Host: $config.host

View File

@@ -355,7 +355,8 @@ fn handle_conn<T>(mut conn net.TcpConn, mut app T) {
//}
// read body
mut read_body := []byte{len: len}
reader.read(mut read_body) // read just the amount of content len if there is no content there is nothing more to read here
// read just the amount of content len if there is no content there is nothing more to read here
reader.read(mut read_body) or { println('reader.read failed with err: $err') }
body += read_body.bytestr()
break
}