Skip to content

Instantly share code, notes, and snippets.

@mapix
Created April 17, 2017 15:11
Show Gist options
  • Save mapix/2bddba64021e51807244728c86a35a13 to your computer and use it in GitHub Desktop.
Save mapix/2bddba64021e51807244728c86a35a13 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"os"
)
func foo() error {
var err error
return err
}
func bar() error {
var err *os.PathError
return err
}
func main() {
if err := foo(); err == nil {
fmt.Println("foo nil")
}
if err := bar(); err == nil {
fmt.Println("bar nil")
}
if err := bar(); err.(*os.PathError) == nil {
fmt.Println("bar2 nil")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment