posts/rust/update-hosts/ #1
Replies: 2 comments
-
fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
println!("Starting updatehosts4r...");
download_hosts_file()?;
println!("Hosts file downloaded successfully.");
println!("Parsing hosts file...");
run_select_fastest_ips()?;
println!("Hosts file parsed successfully.");
copy_and_flush_dns()?;
println!("Hosts file updated and DNS cache flushed.");
// Clean up temporary files
std::fs::remove_file(TEMP_FILE_PATH)?;
print!("Temporary file {} removed.\n", TEMP_FILE_PATH);
std::fs::remove_file(TEMP_HOSTS_FILE_PATH)?;
println!("Temporary files cleaned up.");
// show press any key to exit
println!("Press any key to exit...");
let mut input = String::new();
std::io::stdin().read_line(&mut input)?;
Ok(()) // Explicitly return Ok(())
} 听一位兄弟的劝,把main函数写成了这样,防止被说是像golang |
Beta Was this translation helpful? Give feedback.
0 replies
-
最近有学了一个: cargo install --git https://github.com/qchen-fdii-cardc/updatehosts4r.git 就会把源代码下载到零时文件夹,然后编译成exe,然后: get-command updatehosts4r 查看装在哪里了。 start-process updatehosts4r -verb runas 直接确认用管理员权限运行,可以修改hosts文件。 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
posts/rust/update-hosts/
Rust启动
说真的,我挺不喜欢锈粉(Rustaceans)那股味道的,就好像我家两个原神粉(老婆和孩子)天天攻击我说魔兽世界是垃圾游戏一样,我,我,我打,我打扫卫生去……
https://www.windtunnel.cn/posts/rust/update-hosts/
Beta Was this translation helpful? Give feedback.
All reactions