cloudflare / pingora

A library for building fast, reliable and evolvable network services.
Apache License 2.0
21.42k stars 1.18k forks source link

快速入门指南中的示例代码问题 #107

Closed zjwztttt closed 6 months ago

zjwztttt commented 7 months ago

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

zjwztttt commented 7 months ago

上面解决办法写完后发现错了,实际正确的解决方法是改成以下这种写法: println!("upstream peer is: {:?}",upstream);

Tallone commented 7 months ago

May be you should pull last commit.

info!("upstream peer is: {:?}", upstream);
foxwhite25 commented 7 months ago

The correct way to use debug format with variable name in the template string is

info!("upstream peer is: {upstream:?}");
ambi88dex commented 7 months ago

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?

johnhurt commented 6 months ago

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.