pingora
pingora copied to clipboard
快速入门指南中的示例代码问题
Describe the bug
在入门指南示例代码中的下面一行源码缺少一对花括号“{}”,比如: println!("upstream peer is: {:upstream?}"); 应该改成: println!("upstream peer is: {{:upstream?}}");
Pingora info
Please include the following information about your environment:
Pingora version: 0.1 Rust version: 1.76 Operating system version: Debian 12.4
报以下错误
error: invalid format string: expected '}'
, found '?'
--> src/main.rs:21:47
|
21 | println!("upstream peer is: {:upstream?}");
| - ^ expected '}'
in format string
| |
| because of this opening brace
|
= note: if you intended to print {
, you can escape it using {{
error: could not compile load_balancer
(bin "load_balancer") due to 1 previous error
上面解决办法写完后发现错了,实际正确的解决方法是改成以下这种写法: println!("upstream peer is: {:?}",upstream);
May be you should pull last commit.
info!("upstream peer is: {:?}", upstream);
The correct way to use debug format with variable name in the template string is
info!("upstream peer is: {upstream:?}");
Thanks to google translate that I could understand the issuer's concern. But is there a norm where there is a certain language to be followed for global understanding?
This issue was totally my fault. The code in the quick-start guide isn't checked directly, but maybe it could converted to a doc test. It has been fixed now in the main branch, so this issue should be resolved.