Sobes.tech
Junior — Senior

What will be the output of the checkErr function in main

livecode

Task condition

What boolean values will the function checkErr print for different calls from main?

import (
  "fmt"
)

type errorString struct {
  s string
}

func (e errorString) Error() string {
  return e.s
}

func checkErr(err error) {
  fmt.Println(err == nil)
}

func main() {
  var err1 error
  checkErr(err1)

  var errPtr *errorString
  checkErr(errPtr)

  errPtr = &errorString{}
  checkErr(errPtr)

  errPtr = nil
  checkErr(errPtr)
}