github.com/graybobo/golang.org-package-offline-cache@v0.0.0-20200626051047-6608995c132f/x/talks/2014/readability/nil_error.go (about)

     1  // +build OMIT
     2  
     3  package main // OMIT
     4  
     5  import "log"
     6  
     7  type FooError struct{}
     8  
     9  func (e *FooError) Error() string { return "foo error" }
    10  
    11  func foo() error {
    12  	var ferr *FooError // ferr == nil // HL
    13  	return ferr
    14  }
    15  func main() {
    16  	err := foo()
    17  	if err != nil { // HL
    18  		log.Fatal(err)
    19  	}
    20  }