Error Handling in Go

Go 原生的 Error Type 先認識 go 的 error interface 1 2 3 type error interface { Error() string } 只要 struct 實作 Error() 方法,就會是 error type,例如 os package 裡面的 PathError https://golang.org/pkg/os/#PathError 1 2 3 4 5 6 7 8 // PathError records an error and the operation and file path that...

26 July 2018 · 1 min · nyo