8.2 错误处理概念
一、错误处理
在代码异常时候将异常抛出即可
file, err := os.Open("abx.txt") if err != nil { if pathError, ok := err.(*os.PathError); ok { fmt.Println(pathError.Err) } else { fmt.Println("unknow error:", err) } }备注:获取错误并输出即可
Last updated
Was this helpful?