Skip to content

Instantly share code, notes, and snippets.

@mvo5
Last active March 15, 2023 08:37
Show Gist options
  • Save mvo5/0586ab732a3fcb8547145586d82fd409 to your computer and use it in GitHub Desktop.
Save mvo5/0586ab732a3fcb8547145586d82fd409 to your computer and use it in GitHub Desktop.
Go can have weird behavior for nil - this illustrates one pitfal.
package main
import (
"fmt"
"os"
)
func foo() error {
err := &os.SyscallError{}
err = nil
return err
}
func main() {
if err := foo(); err != nil {
fmt.Printf("err is: %[1]p %[1]v (%[1]T)\n", err)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment