Answers for "struct is not nil golang"

Go
0

struct is not nil golang

package main

import "fmt"
import "time"
import "reflect"

type Session struct {
    playerId string
    beehive string
    timestamp time.Time
}

func (s Session) IsEmpty() bool {
  return reflect.DeepEqual(s,Session{})
}

func main() {
  x := Session{}
  if x.IsEmpty() {
    fmt.Print("is empty")
  } 
}
Posted by: Guest on March-22-2020

Code answers related to "struct is not nil golang"

Browse Popular Code Answers by Language