ZhangZhihui's Blog  
上一页 1 ··· 83 84 85 86 87 88 89 90 91 ··· 102 下一页

2023年10月1日

摘要: Using io.Copy is about twice as fast and uses only a fraction (less than 1%) of the memory. With really large files, if you’re using the io.ReadAll an 阅读全文
posted @ 2023-10-01 20:20 ZhangZhihuiAAA 阅读(31) 评论(0) 推荐(0)

2023年9月30日

摘要: package main import "fmt" func adder() func(int) int { sum := 0 return func(x int) int { sum += x return sum } } func main() { pos, neg := adder(), ad 阅读全文
posted @ 2023-09-30 10:14 ZhangZhihuiAAA 阅读(18) 评论(0) 推荐(0)
 
摘要: Problem: You want to log in to the system log instead of your logfiles. Solution: Use the log/syslog package to write to syslog. Syslog is a standard 阅读全文
posted @ 2023-09-30 08:20 ZhangZhihuiAAA 阅读(36) 评论(0) 推荐(0)

2023年9月29日

摘要: Examples of log levels from high to low are: • Fatal • Error• Warn • Info • Debug To set up log levels for your logs, you can add the level to each li 阅读全文
posted @ 2023-09-29 17:55 ZhangZhihuiAAA 阅读(41) 评论(0) 推荐(0)
 
摘要: Problem: You want to log events to a logfile instead of standard error. Solution: Use the SetOutput function to set the log to write to a file. You us 阅读全文
posted @ 2023-09-29 15:15 ZhangZhihuiAAA 阅读(17) 评论(0) 推荐(0)
 
摘要: Problem: You want to check for specific errors or specific types of errors. Solution: Use the errors.Is and errors.As functions. The errors.Is functio 阅读全文
posted @ 2023-09-29 14:24 ZhangZhihuiAAA 阅读(20) 评论(0) 推荐(0)
 
摘要: Problem: You want to provide additional information and context to an error you receive before returning it as another error. Solution: Wrap the error 阅读全文
posted @ 2023-09-29 10:24 ZhangZhihuiAAA 阅读(15) 评论(0) 推荐(0)
 
摘要: Problem: You want to create custom errors to communicate more information about the error encountered. Solution: Create a new string - based error or 阅读全文
posted @ 2023-09-29 10:11 ZhangZhihuiAAA 阅读(20) 评论(0) 推荐(0)
 
摘要: Problem: You want to use multiple versions of the same dependent packages in your code. Solution: Use the replace directive in the go.mod file to rena 阅读全文
posted @ 2023-09-29 09:17 ZhangZhihuiAAA 阅读(89) 评论(0) 推荐(0)
 
摘要: Problem: You want to use local versions of the dependent packages. Solution: Set up Go to use a vendor directory by running go mod vendor. Local versi 阅读全文
posted @ 2023-09-29 08:53 ZhangZhihuiAAA 阅读(11) 评论(0) 推荐(0)
上一页 1 ··· 83 84 85 86 87 88 89 90 91 ··· 102 下一页