First of all, look at the following code snippet:
package main
import (
"fmt"
)
func main() {
var para1 struct {
email, addr string
}
para1.email = "test@test.com"
if para1 != nil {
fmt.Println(para1)
}
}
When I compile this code, I've got the compiler error:
./struct_func.go:15: cannot convert nil to type struct { email string; addr string }
How can I validate if my struct variable, if nil or not? Or I have to validate of property like
if para1.email != nil {
fmt.Println(para1)
}