diff --git a/cmd/tools/bench/wyhash.v b/cmd/tools/bench/wyhash.v index 68806ca721..0f478914d2 100644 --- a/cmd/tools/bench/wyhash.v +++ b/cmd/tools/bench/wyhash.v @@ -10,11 +10,11 @@ fn main() { min_str_len := 20 max_str_len := 40 println('Generating $sample_size strings between $min_str_len - $max_str_len chars long...') - mut bytepile := []byte + mut bytepile := []byte{} for _ in 0 .. sample_size * max_str_len { bytepile << byte(40 + rand.next(125 - 40)) } - mut str_lens := []int + mut str_lens := []int{} for _ in 0 .. sample_size { str_lens << min_str_len + rand.next(max_str_len - min_str_len) } diff --git a/cmd/tools/modules/testing/common.v b/cmd/tools/modules/testing/common.v index 9b1333d7e1..1709f23678 100644 --- a/cmd/tools/modules/testing/common.v +++ b/cmd/tools/modules/testing/common.v @@ -34,7 +34,7 @@ pub fn (mh mut TestMessageHandler) append_message(msg string) { } pub fn new_test_session(_vargs string) TestSession { - mut skip_files := []string + mut skip_files := []string{} skip_files << '_non_existing_' $if solaris { skip_files << "examples/gg/gg2.v" @@ -59,7 +59,7 @@ pub fn (ts mut TestSession) init() { pub fn (ts mut TestSession) test() { ts.init() - mut remaining_files := []string + mut remaining_files := []string{} for dot_relative_file in ts.files { relative_file := dot_relative_file.replace('./', '') file := os.real_path(relative_file) @@ -225,7 +225,7 @@ pub fn v_build_failing(zargs string, folder string) bool { eprintln('v compiler args: "$vargs"') mut session := new_test_session(vargs) files := os.walk_ext(os.join_path(parent_dir, folder), '.v') - mut mains := []string + mut mains := []string{} for f in files { if !f.contains('modules') && !f.contains('preludes') { $if windows { diff --git a/cmd/tools/performance_compare.v b/cmd/tools/performance_compare.v index d619e8cb62..ffa979cd29 100644 --- a/cmd/tools/performance_compare.v +++ b/cmd/tools/performance_compare.v @@ -51,7 +51,7 @@ fn (c Context) compare_versions() { // The first is the baseline, against which all the others will be compared. // It is the fastest, since hello_world.v has only a single println in it, - mut perf_files := []string + mut perf_files := []string{} perf_files << c.compare_v_performance('source_hello', [ 'vprod @DEBUG@ -o source.c examples/hello_world.v', 'vprod -o source.c examples/hello_world.v', @@ -147,7 +147,7 @@ fn (c Context) compare_v_performance(label string, commands []string) string { timestamp_b,_ := vgit.line_to_timestamp_and_commit(scripting.run('cd $c.b/ ; git rev-list -n1 --timestamp HEAD')) debug_option_a := if timestamp_a > 1570877641 { '-g ' } else { '-debug ' } debug_option_b := if timestamp_b > 1570877641 { '-g ' } else { '-debug ' } - mut hyperfine_commands_arguments := []string + mut hyperfine_commands_arguments := []string{} for cmd in commands { println(cmd) } diff --git a/cmd/tools/vbin2v.v b/cmd/tools/vbin2v.v index 16b255989b..802e055cec 100644 --- a/cmd/tools/vbin2v.v +++ b/cmd/tools/vbin2v.v @@ -20,7 +20,7 @@ fn (context Context) header() { println('module ${context.module_name}') println('') allfiles := context.files.join(' ') - mut options := []string + mut options := []string{} if context.prefix.len > 0 { options << '-p ${context.prefix}' } diff --git a/cmd/tools/vfmt.v b/cmd/tools/vfmt.v index 48f1e29d20..d7de886fda 100644 --- a/cmd/tools/vfmt.v +++ b/cmd/tools/vfmt.v @@ -74,7 +74,7 @@ fn main() { eprintln('vfmt env_vflags_and_os_args: ' + args.str()) eprintln('vfmt possible_files: ' + possible_files.str()) } - mut files := []string + mut files := []string{} for file in possible_files { if !file.ends_with('.v') && !file.ends_with('.vv') { verror('v fmt can only be used on .v files.\nOffending file: "$file"') @@ -90,7 +90,7 @@ fn main() { vhelp.show_topic('fmt') exit(0) } - mut cli_args_no_files := []string + mut cli_args_no_files := []string{} for a in os.args { if a !in files { cli_args_no_files << a @@ -287,7 +287,7 @@ fn get_compile_name_of_potential_v_project(file string) string { all_files_in_pfolder := os.ls(pfolder) or { panic(err) } - mut vfiles := []string + mut vfiles := []string{} for f in all_files_in_pfolder { vf := os.join_path(pfolder, f) if f.starts_with('.') || !f.ends_with('.v') || os.is_dir(vf) { diff --git a/cmd/tools/vnames.v b/cmd/tools/vnames.v index 6d8c787fed..202c9f74a5 100644 --- a/cmd/tools/vnames.v +++ b/cmd/tools/vnames.v @@ -70,7 +70,7 @@ fn main(){ exit(0) } - mut files := []string + mut files := []string{} locations := fp.finalize() or { eprintln('Error: ' + err) exit(1) } for xloc in locations { loc := os.real_path(xloc) diff --git a/cmd/tools/vpm.v b/cmd/tools/vpm.v index f35534d0ee..8f11153e74 100644 --- a/cmd/tools/vpm.v +++ b/cmd/tools/vpm.v @@ -275,7 +275,7 @@ fn vpm_help() { } fn vcs_used_in_dir(dir string) ?[]string { - mut vcs := []string + mut vcs := []string{} for repo_subfolder in supported_vcs_folders { checked_folder := os.real_path(os.join_path(dir,repo_subfolder)) if os.is_dir(checked_folder) { @@ -292,7 +292,7 @@ fn get_installed_modules() []string { dirs := os.ls(settings.vmodules_path) or { return [] } - mut modules := []string + mut modules := []string{} for dir in dirs { adir := os.join_path(settings.vmodules_path,dir) if dir in excluded_dirs || !os.is_dir(adir) { @@ -323,7 +323,7 @@ fn get_all_modules() []string { } s := r.text mut read_len := 0 - mut modules := []string + mut modules := []string{} for read_len < s.len { mut start_token := '') parsed := fs.parse_value(name, abbr) - mut value := []int + mut value := []int{} for val in parsed { value << val.int() } @@ -294,7 +294,7 @@ pub fn (fs mut FlagParser) int(name string, abbr byte, idefault int, usage strin pub fn (fs mut FlagParser) float_multi(name string, abbr byte, usage string) []f64 { fs.add_flag(name, abbr, usage, '') parsed := fs.parse_value(name, abbr) - mut value := []f64 + mut value := []f64{} for val in parsed { value << val.f64() } @@ -421,7 +421,7 @@ pub fn (fs FlagParser) usage() string { use += 'This application does not expect any arguments\n\n' goto end_of_arguments_handling } - mut s:= []string + mut s:= []string{} if positive_min_arg { s << 'at least $fs.min_free_args' } if positive_max_arg { s << 'at most $fs.max_free_args' } if positive_min_arg && positive_max_arg && fs.min_free_args == fs.max_free_args { diff --git a/vlib/gg2/gg.v b/vlib/gg2/gg.v index 8190aa9fcc..3b755c7a07 100644 --- a/vlib/gg2/gg.v +++ b/vlib/gg2/gg.v @@ -3,16 +3,15 @@ // that can be found in the LICENSE file. module gg2 -import ( - glm - gx - os - sokol - sokol.sapp - sokol.sgl - sokol.gfx - sokol.sfons -) +import glm +import gx +import os +import sokol +import sokol.sapp +import sokol.sgl +import sokol.gfx +import sokol.sfons + const ( default_font_size = 24 ) diff --git a/vlib/log/log.v b/vlib/log/log.v index 97eaac0281..4df86e2126 100644 --- a/vlib/log/log.v +++ b/vlib/log/log.v @@ -1,10 +1,8 @@ module log -import ( - os - time - term -) +import os +import time +import term pub enum Level { fatal = 1 diff --git a/vlib/math/factorial/factorial.v b/vlib/math/factorial/factorial.v index 8a534438f9..ad173b8f54 100644 --- a/vlib/math/factorial/factorial.v +++ b/vlib/math/factorial/factorial.v @@ -48,7 +48,7 @@ pub fn log_factorial(n f64) f64 { fn log_factorial_asymptotic_expansion(n int) f64 { m := 6 - mut term := []f64 + mut term := []f64{} xx := f64((n + 1) * (n + 1)) mut xj := f64(n + 1) diff --git a/vlib/math/stats/stats.v b/vlib/math/stats/stats.v index 8affafd1fa..77915f016a 100644 --- a/vlib/math/stats/stats.v +++ b/vlib/math/stats/stats.v @@ -2,21 +2,21 @@ module stats import math -// TODO: Implement all of them with generics +// TODO: Implement all of them with generics -// This module defines the following statistical operations on f64 array +// This module defines the following statistical operations on f64 array // --------------------------- // | Summary of Functions | // --------------------------- // ----------------------------------------------------------------------- // freq - Frequency -// mean - Mean +// mean - Mean // geometric_mean - Geometric Mean // harmonic_mean - Harmonic Mean // median - Median // mode - Mode // rms - Root Mean Square -// population_variance - Population Variance +// population_variance - Population Variance // sample_variance - Sample Variance // population_stddev - Population Standard Deviation // sample_stddev - Sample Standard Deviation @@ -29,7 +29,7 @@ import math // Measure of Occurance // Frequency of a given number -// Based on +// Based on // https://www.mathsisfun.com/data/frequency-distribution.html pub fn freq(arr []f64, val f64) int { if arr.len == 0 { @@ -46,7 +46,7 @@ pub fn freq(arr []f64, val f64) int { // Measure of Central Tendancy // Mean of the given input array -// Based on +// Based on // https://www.mathsisfun.com/data/central-measures.html pub fn mean(arr []f64) f64 { if arr.len == 0 { @@ -61,7 +61,7 @@ pub fn mean(arr []f64) f64 { // Measure of Central Tendancy // Geometric Mean of the given input array -// Based on +// Based on // https://www.mathsisfun.com/numbers/geometric-mean.html pub fn geometric_mean(arr []f64) f64 { if arr.len == 0 { @@ -76,7 +76,7 @@ pub fn geometric_mean(arr []f64) f64 { // Measure of Central Tendancy // Harmonic Mean of the given input array -// Based on +// Based on // https://www.mathsisfun.com/numbers/harmonic-mean.html pub fn harmonic_mean(arr []f64) f64 { if arr.len == 0 { @@ -91,7 +91,7 @@ pub fn harmonic_mean(arr []f64) f64 { // Measure of Central Tendancy // Median of the given input array ( input array is assumed to be sorted ) -// Based on +// Based on // https://www.mathsisfun.com/data/central-measures.html pub fn median(arr []f64) f64 { if arr.len == 0 { @@ -108,13 +108,13 @@ pub fn median(arr []f64) f64 { // Measure of Central Tendancy // Mode of the given input array -// Based on +// Based on // https://www.mathsisfun.com/data/central-measures.html pub fn mode(arr []f64) f64 { if arr.len == 0 { return f64(0) } - mut freqs := []int + mut freqs := []int{} for v in arr { freqs<1 { diff --git a/vlib/net/http/cookie.v b/vlib/net/http/cookie.v index 5070bc7a9c..ddc2ccc8e2 100644 --- a/vlib/net/http/cookie.v +++ b/vlib/net/http/cookie.v @@ -3,11 +3,9 @@ // that can be found in the LICENSE file. module http -import ( - time - arrays - strings -) +import time +import arrays +import strings pub struct Cookie { pub mut: diff --git a/vlib/net/http/cookie_test.v b/vlib/net/http/cookie_test.v index 59b94b0439..49d2ee9553 100644 --- a/vlib/net/http/cookie_test.v +++ b/vlib/net/http/cookie_test.v @@ -1,7 +1,5 @@ -import ( - net.http - time -) +import net.http +import time struct SetCookieTestCase { cookie &http.Cookie diff --git a/vlib/net/http/http.v b/vlib/net/http/http.v index d27a6cfe8b..e1951993d7 100644 --- a/vlib/net/http/http.v +++ b/vlib/net/http/http.v @@ -128,7 +128,7 @@ pub fn get_text(url string) string { } pub fn url_encode_form_data(data map[string]string) string { - mut pieces := []string + mut pieces := []string{} for _key, _value in data { key := urllib.query_escape(_key) value := urllib.query_escape(_value) @@ -151,7 +151,7 @@ fn build_url_from_fetch(_url string, config FetchConfig) ?string { if params.keys().len == 0 { return url.str() } - mut pieces := []string + mut pieces := []string{} for key in params.keys() { pieces << '${key}=${params[key]}' } @@ -314,7 +314,7 @@ fn parse_response(resp string) Response { fn (req &Request) build_request_headers(method, host_name, path string) string { ua := req.user_agent - mut uheaders := []string + mut uheaders := []string{} if 'Host' !in req.headers { uheaders << 'Host: $host_name\r\n' } @@ -338,7 +338,7 @@ fn (req &Request) build_request_cookies_header() string { if req.cookies.keys().len < 1 { return '' } - mut cookie := []string + mut cookie := []string{} for key, val in req.cookies { cookie << '$key: $val' } diff --git a/vlib/net/urllib/urllib.v b/vlib/net/urllib/urllib.v index a4a6f8a3dc..6ef5d277f0 100644 --- a/vlib/net/urllib/urllib.v +++ b/vlib/net/urllib/urllib.v @@ -257,7 +257,7 @@ fn escape(s string, mode EncodingMode) string { return s } buf := [byte(0)].repeat(64) - mut t := []byte + mut t := []byte{} required := s.len + 2 * hex_count if required <= buf.len { t = buf[..required] @@ -883,7 +883,7 @@ pub fn (v Values) encode() string { return '' } mut buf := strings.new_builder(200) - mut keys := []string + mut keys := []string{} for k, _ in v.data { keys << k } @@ -922,7 +922,7 @@ fn resolve_path(base, ref string) string { if full == '' { return '' } - mut dst := []string + mut dst := []string{} src := full.split('/') for _, elem in src { match elem { @@ -1131,4 +1131,3 @@ fn unhex(c byte) byte { } return 0 } - diff --git a/vlib/net/websocket/examples/client.v b/vlib/net/websocket/examples/client.v index 00fa9897b2..749f86ba94 100644 --- a/vlib/net/websocket/examples/client.v +++ b/vlib/net/websocket/examples/client.v @@ -1,13 +1,11 @@ module main -import ( - net.websocket - eventbus - time - readline - term - benchmark -) +import net.websocket +import eventbus +import time +import readline +import term +import benchmark const ( eb = eventbus.new() diff --git a/vlib/net/websocket/utils.v b/vlib/net/websocket/utils.v index 76df52d8f6..abc345ba1b 100644 --- a/vlib/net/websocket/utils.v +++ b/vlib/net/websocket/utils.v @@ -1,12 +1,10 @@ module websocket -import ( - time - rand - math - crypto.sha1 - encoding.base64 -) +import time +import rand +import math +import crypto.sha1 +import encoding.base64 fn htonl64(payload_len u64) byteptr { mut ret := malloc(8) @@ -18,7 +16,7 @@ fn htonl64(payload_len u64) byteptr { ret[4] = byte(((payload_len & (u64(0xff) << 24)) >> 24) & 0xff) ret[5] = byte(((payload_len & (u64(0xff) << 16)) >> 16) & 0xff) ret[6] = byte(((payload_len & (u64(0xff) << 8)) >> 8) & 0xff) - ret[7] = byte(((payload_len & (u64(0xff) << 0)) >> 0) & 0xff) + ret[7] = byte(((payload_len & (u64(0xff) << 0)) >> 0) & 0xff) return ret } @@ -46,7 +44,7 @@ fn create_key_challenge_response(seckey string) string { } fn get_nonce() string { - mut nonce := []byte + mut nonce := []byte{} alphanum := "0123456789ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvwxyz" for i in 0..18 { nonce << alphanum[rand.next(61)] diff --git a/vlib/net/websocket/ws.v b/vlib/net/websocket/ws.v index 9b4e8b1737..119f130e67 100644 --- a/vlib/net/websocket/ws.v +++ b/vlib/net/websocket/ws.v @@ -1,13 +1,11 @@ module websocket -import ( - net - net.urllib - encoding.base64 - eventbus - sync - net.websocket.logger -) +import net +import net.urllib +import encoding.base64 +import eventbus +import sync +import net.websocket.logger const ( l = logger.new("ws") @@ -147,7 +145,7 @@ pub fn (ws mut Client) connect() int { l.d("handshake header:") handshake := "GET ${uri.resource}${uri.querystring} HTTP/1.1\r\nHost: ${uri.hostname}:${uri.port}\r\nUpgrade: websocket\r\nConnection: Upgrade\r\nSec-WebSocket-Key: ${seckey}\r\nSec-WebSocket-Version: 13\r\n\r\n" l.d(handshake) - + socket := net.new_socket(ai_family, ai_socktype, 0) or { l.f(err) return -1 @@ -542,7 +540,7 @@ pub fn (ws mut Client) read() int { goto free_data return -1 } - mut payload := []byte + mut payload := []byte{} if payload_len > 0 { payload = [`0`].repeat(int(payload_len)) C.memcpy(payload.data, &data[header_len], payload_len) diff --git a/vlib/os/os_windows.c.v b/vlib/os/os_windows.c.v index 3bef506178..c244c96f59 100644 --- a/vlib/os/os_windows.c.v +++ b/vlib/os/os_windows.c.v @@ -77,7 +77,7 @@ mut: } fn init_os_args_wide(argc int, argv &byteptr) []string { - mut args := []string + mut args := []string{} for i in 0..argc { args << string_from_wide(&u16(argv[i])) } @@ -86,7 +86,7 @@ fn init_os_args_wide(argc int, argv &byteptr) []string { pub fn ls(path string) ?[]string { mut find_file_data := Win32finddata{} - mut dir_files := []string + mut dir_files := []string{} // We can also check if the handle is valid. but using is_dir instead // h_find_dir := C.FindFirstFile(path.str, &find_file_data) // if (INVALID_HANDLE_VALUE == h_find_dir) { diff --git a/vlib/rand/pcg32_test.v b/vlib/rand/pcg32_test.v index 546b7c7331..ad68ee771a 100644 --- a/vlib/rand/pcg32_test.v +++ b/vlib/rand/pcg32_test.v @@ -3,7 +3,7 @@ import rand import time fn show_u32s(a []u32){ - mut res := []string + mut res := []string{} for x in a { res << x.str() } @@ -32,5 +32,5 @@ fn test_pcg32_reproducibility() { len := randoms1.len for i in 0..len { assert randoms1[i] == randoms2[i] - } + } } diff --git a/vlib/rand/splitmix64_test.v b/vlib/rand/splitmix64_test.v index 4f92b1eca4..6f3adebd58 100644 --- a/vlib/rand/splitmix64_test.v +++ b/vlib/rand/splitmix64_test.v @@ -3,7 +3,7 @@ import rand import time fn show_u64s(a []u64){ - mut res := []string + mut res := []string{} for x in a { res << x.str() } @@ -32,5 +32,5 @@ fn test_splitmix64_reproducibility() { len := randoms1.len for i in 0..len { assert randoms1[i] == randoms2[i] - } + } } diff --git a/vlib/regex/regex.v b/vlib/regex/regex.v index b56476c2d4..4915839c09 100644 --- a/vlib/regex/regex.v +++ b/vlib/regex/regex.v @@ -2232,7 +2232,7 @@ pub fn (re mut RE) find(in_txt string) (int,int) { // find all the non overlapping occurrences of the match pattern pub fn (re mut RE) find_all(in_txt string) []int { mut i := 0 - mut res := []int + mut res := []int{} mut ls := -1 for i < in_txt.len { s,e := re.find(in_txt[i..]) diff --git a/vlib/strconv/atof_test.v b/vlib/strconv/atof_test.v index 44a2d6e668..121dda9570 100644 --- a/vlib/strconv/atof_test.v +++ b/vlib/strconv/atof_test.v @@ -3,10 +3,8 @@ * String to float Test * **********************************************************************/ -import ( - strconv - strconv.atofq -) +import strconv +import strconv.atofq fn test_atof() { // diff --git a/vlib/v/gen/cgen.v b/vlib/v/gen/cgen.v index 96449c455b..dab75dcc9b 100644 --- a/vlib/v/gen/cgen.v +++ b/vlib/v/gen/cgen.v @@ -2010,7 +2010,7 @@ fn (mut g Gen) struct_init(struct_init ast.StructInit) { } else { g.writeln('($styp){') } - // mut fields := []string + // mut fields := []string{} mut inited_fields := []string{} // TODO this is done in checker, move to ast node /* if struct_init.fields.len == 0 && struct_init.exprs.len > 0 { diff --git a/vlib/v/gen/fn.v b/vlib/v/gen/fn.v index 4c7b30b02e..8a207fe994 100644 --- a/vlib/v/gen/fn.v +++ b/vlib/v/gen/fn.v @@ -367,7 +367,7 @@ fn (mut g Gen) fn_call(node ast.CallExpr) { } // Generate tmp vars for values that have to be freed. /* - mut tmps := []string + mut tmps := []string{} for arg in node.args { if arg.typ == table.string_type_idx || is_print { tmp := g.new_tmp_var() diff --git a/vlib/v/parser/parser_test.v b/vlib/v/parser/parser_test.v index b12ad13ea5..9008ae7e88 100644 --- a/vlib/v/parser/parser_test.v +++ b/vlib/v/parser/parser_test.v @@ -1,14 +1,12 @@ module parser -import ( - v.ast - v.gen - v.table - v.checker - // v.eval - v.pref - term -) +import v.ast +import v.gen +import v.table +import v.checker +//import v.eval +import v.pref +import term fn test_eval() { /* diff --git a/vlib/v/tests/inout/empty_import.out b/vlib/v/tests/inout/empty_import.out deleted file mode 100644 index c1e44f4f09..0000000000 --- a/vlib/v/tests/inout/empty_import.out +++ /dev/null @@ -1 +0,0 @@ -empty import \ No newline at end of file diff --git a/vlib/v/tests/inout/empty_import.vv b/vlib/v/tests/inout/empty_import.vv deleted file mode 100644 index ada986a14a..0000000000 --- a/vlib/v/tests/inout/empty_import.vv +++ /dev/null @@ -1,7 +0,0 @@ -import ( - // no module -) - -fn main() { - println('empty import') -} diff --git a/vlib/v/tests/live_test.v b/vlib/v/tests/live_test.v index cb6e139438..c3aa7f60d5 100755 --- a/vlib/v/tests/live_test.v +++ b/vlib/v/tests/live_test.v @@ -1,7 +1,5 @@ -import ( - os - time -) +import os +import time const ( vexe = os.getenv('VEXE') diff --git a/vlib/v/tests/module_test.v b/vlib/v/tests/module_test.v index 87b189c656..cf48516951 100644 --- a/vlib/v/tests/module_test.v +++ b/vlib/v/tests/module_test.v @@ -1,11 +1,9 @@ -import ( - os - time as t - crypto.sha256 - math - log as l - crypto.sha512 -) +import os +import time as t +import crypto.sha256 +import math +import log as l +import crypto.sha512 struct TestAliasInStruct { time t.Time @@ -13,7 +11,7 @@ struct TestAliasInStruct { fn test_import() { info := l.Level.info - assert os.O_RDONLY == os.O_RDONLY && t.month_days[0] == t.month_days[0] && sha256.size == + assert os.O_RDONLY == os.O_RDONLY && t.month_days[0] == t.month_days[0] && sha256.size == sha256.size && math.pi == math.pi && info == .info && sha512.size == sha512.size } diff --git a/vlib/v/tests/prod_test.v b/vlib/v/tests/prod_test.v index 90e013184d..81c2b56521 100644 --- a/vlib/v/tests/prod_test.v +++ b/vlib/v/tests/prod_test.v @@ -1,10 +1,7 @@ // Build and run files in ./prod/ folder, comparing their output to *.expected.txt files. // (Similar to REPL tests, but in -prod mode.) -// import os -import ( - v.tests.repl.runner - benchmark -) +import v.tests.repl.runner +import benchmark fn test_all_v_prod_files() { // TODO: Fix running this test on Windows: diff --git a/vlib/v/tests/repl/runner/runner.v b/vlib/v/tests/repl/runner/runner.v index a108e93192..01ae3e5f44 100644 --- a/vlib/v/tests/repl/runner/runner.v +++ b/vlib/v/tests/repl/runner/runner.v @@ -130,7 +130,7 @@ $diff pub fn new_options() RunnerOptions { vexec := full_path_to_v(5) mut wd := os.getwd() - mut files := []string + mut files := []string{} if os.args.len > 1 { files = os.args[1..] } else { @@ -148,7 +148,7 @@ pub fn new_options() RunnerOptions { pub fn new_prod_options() RunnerOptions { wd := os.getwd() vexec := full_path_to_v(4) - mut files := []string + mut files := []string{} if os.args.len > 1 { files = os.args[1..] } else { diff --git a/vlib/v/tests/typeof_test.v b/vlib/v/tests/typeof_test.v index f1d7563f78..347568950d 100644 --- a/vlib/v/tests/typeof_test.v +++ b/vlib/v/tests/typeof_test.v @@ -8,8 +8,8 @@ fn test_typeof_on_simple_expressions() { } fn test_typeof_on_atypes() { - aint := []int - astring := []string + aint := []int{} + astring := []string{} assert typeof(aint) == 'array_int' assert typeof(astring) == 'array_string' } diff --git a/vlib/vweb/assets/assets.v b/vlib/vweb/assets/assets.v index cb1e8be706..f6258a7e3c 100644 --- a/vlib/vweb/assets/assets.v +++ b/vlib/vweb/assets/assets.v @@ -3,11 +3,9 @@ module assets // this module provides an AssetManager for combining // and caching javascript & css. -import ( - os - time - crypto.md5 -) +import os +import time +import crypto.md5 const ( UnknownAssetTypeError = 'vweb.assets: unknown asset type' @@ -21,7 +19,7 @@ pub mut: // when true assets will be minified minify bool // the directory to store the cached/combined files - cache_dir string + cache_dir string } struct Asset { @@ -75,11 +73,11 @@ fn (am AssetManager) combine(asset_type string, to_file bool) string { cache_key := am.get_cache_key(asset_type) out_file := '$am.cache_dir/${cache_key}.$asset_type' mut out := '' - // use cache + // use cache if os.exists(out_file) { if to_file { return out_file - } + } cached := os.read_file(out_file) or { return '' } diff --git a/vlib/vweb/assets/assets_test.v b/vlib/vweb/assets/assets_test.v index 96c0014706..b0b2f42f39 100644 --- a/vlib/vweb/assets/assets_test.v +++ b/vlib/vweb/assets/assets_test.v @@ -1,7 +1,5 @@ -import ( - vweb.assets - os -) +import vweb.assets +import os // clean_cache_dir used before and after tests that write to a cache directory. // Because of parallel compilation and therefore test running, diff --git a/vlib/vweb/vweb.v b/vlib/vweb/vweb.v index 6ccbe99c13..bb43a742fe 100644 --- a/vlib/vweb/vweb.v +++ b/vlib/vweb/vweb.v @@ -4,13 +4,11 @@ module vweb -import ( - os - net - net.http - net.urllib - strings -) +import os +import net +import net.http +import net.urllib +import strings pub const ( methods_with_form = ['POST', 'PUT', 'PATCH'] @@ -186,7 +184,7 @@ fn handle_conn(conn net.Socket, app mut T) { return //continue } - mut headers := []string + mut headers := []string{} mut body := '' mut in_headers := true mut len := 0