https://blog.golang.org/go1.13-errors

https://blog.golang.org/go1.13-errors

https://blog.golang.org/go1.13-errors
 
  • Introduction
  • Examining Errors
  • Adding Information
  • The Unwrap Method
  • Examining Errors with Is and as
  • Wrapping Errors with %W
  • Whether to Wrap
  • Customizing Error Tests with Is and as Methods
  • Errors and Package Apis
  • Conclusion
 
  • Go’s treatment of errors as valueshas served us well over the last decade. Although the standard library’s supportfor errors has been minimal—just the errors.New and fmt.Errorf functions,which produce errors that contain only a message—the built-in error interfaceallows Go programmers to add whatever information they desire. All it requiresis a type that implements an Errormethod: Error types like this one are ubiquitous, and the information they store varieswidely, from timestamps to filenames to server add…
原文地址:https://www.cnblogs.com/rsapaper/p/14694576.html