From 86e6b4f926d6a9760368247647ffc02920cb4c83 Mon Sep 17 00:00:00 2001 From: Mohammad Ali Chraghi <63465728+alic110@users.noreply.github.com> Date: Tue, 9 Feb 2021 13:01:25 +0330 Subject: [PATCH] examples: improve the pg and vweb output (#8640) --- examples/database/pg/customer.v | 10 ++++++---- vlib/vweb/vweb.v | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/examples/database/pg/customer.v b/examples/database/pg/customer.v index 05dd074697..d159b83c6b 100644 --- a/examples/database/pg/customer.v +++ b/examples/database/pg/customer.v @@ -2,6 +2,8 @@ module main import pg +const dash = '----------------------------------------------------------------' + struct Customer { id int name string @@ -24,27 +26,27 @@ fn main() { println('Total customers: $nr_customers') // V syntax can be used to build queries - println('----------------------------------------------------------------') + println(dash) bg_country := 'Bulgaria' bg_customers := db.select from Customer where country == bg_country && id != 2 for customer in bg_customers { println('$customer.country | $customer.id - $customer.name') } - println('----------------------------------------------------------------') + println(dash) ru_customers := db.select from Customer where country == 'Russia' for customer in ru_customers { println('$customer.country | $customer.id - $customer.name') } // by adding `limit 1` we tell V that there will be only one object - println('----------------------------------------------------------------') + println(dash) existing := db.select from Customer where id == 1 limit 1 or { panic(err) } println('Existing customer name: $existing.name') println('Existing customer full information:') println(existing) - println('------------------------------------------------------------------------') + println(dash) q := Customer{} // It's easy to handle queries that don't return any data if anon := db.select from Customer where id == 12345 && name == q.name && diff --git a/vlib/vweb/vweb.v b/vlib/vweb/vweb.v index 22b5d06f0f..445be7a935 100644 --- a/vlib/vweb/vweb.v +++ b/vlib/vweb/vweb.v @@ -266,8 +266,8 @@ pub fn run(port int) { } pub fn run_app(mut app T, port int) { - println('Running a Vweb app on http://localhost:$port') mut l := net.listen_tcp(port) or { panic('failed to listen') } + println('[Vweb] Running app on http://localhost:$port') app.Context = Context{ conn: 0 } @@ -318,7 +318,7 @@ fn handle_conn(mut conn net.TcpConn, mut app T) { page_gen_start := time.ticks() first_line := reader.read_line() or { $if debug { - eprintln('Failed first_line') // show this only in debug mode, because it always would be shown after a chromium user visits the site + eprintln('Failed to read first_line') // show this only in debug mode, because it always would be shown after a chromium user visits the site } return }