摘要:
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
阅读(44)
推荐(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
阅读(29)
推荐(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
阅读(24)
推荐(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
阅读(23)
推荐(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
阅读(30)
推荐(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
阅读(114)
推荐(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
阅读(17)
推荐(0)
摘要:
package main import ( "fmt" "sync" "time" ) var workers = 3 func processItem(input <-chan int, output chan<- int, wg *sync.WaitGroup) { for { fmt.Prin
阅读全文
posted @ 2023-09-27 16:56
ZhangZhihuiAAA
阅读(18)
推荐(0)
摘要:
main.go: package main import "fmt" func main() { ch := make(chan int) ch <- 1 a := <-ch fmt.Println(a) } Got error: zzh@ZZHPC:/zdata/MyPrograms/Go/tes
阅读全文
posted @ 2023-09-27 16:18
ZhangZhihuiAAA
阅读(45)
推荐(0)
摘要:
Within the Kubernetes deployment environment, applications will actually be sent the SIGTERM signal first if it has been decided the pod holding the a
阅读全文
posted @ 2023-09-26 23:00
ZhangZhihuiAAA
阅读(18)
推荐(0)