嘿!我目前正在学习 go lang,我正在对我的概念做一些基本的笔记,尽管我也只是将它们发布在这里。它们没有经过深思熟虑或写得很好,但只是我时不时做笔记以供参考。
我正在学习 maximilian schwarzmüller 的 udemy 课程,
func writebalancefiles(balance float64) { balancetext := fmt.sprint(balance) os.writefile("balance.txt", []byte(balancetext), 0644) }
data, _ := os.readfile("balance.txt")
func readfile() float64 { data, _ := os.readfile("balance.txt") balancetext := string(data) balance, _ := strconv.parsefloat(balancetext, 64) return balance }
var accountbalance, err = readfile() if err != nil { fmt.println("error") fmt.println(err) fmt.println("===============") }
if err != nil { fmt.Println("ERROR") fmt.Println(err) fmt.Println("===============") panic("Can't Continue Sorry!") }
以上就是学习 GO:- 文件处理、错误处理的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号