Sobes.tech
Junior — Senior

Comparison of interface values in Go

livecode

Task condition

Question: What will be the output of the program if you compare the results of calling the functions NewRepo1() and NewRepo2() using the == operator? Consider the following code example:

 type InMemoryRepo struct {
  Value string
}

type Repository interface{}

func NewRepo1() Repository {
  var e *InMemoryRepo
  return e
}

func NewRepo2() Repository {
  return nil
}

func main() {
  fmt.Println(NewRepo1() == NewRepo2())
}